:root {
  color-scheme: dark;
  --felt: #176b35;
  --felt-dark: #07391f;
  --toolbar: rgba(3, 18, 12, 0.74);
  --gold: #d8b45f;
  --cream: #ffffff;
  --muted: #b8c8bc;
  --wood: #110806;
  --wood-light: #2a120d;
  --ink: #181411;
  --red: #bd2f2f;
  --black: #202020;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at center, rgba(216, 180, 95, 0.12), transparent 34%),
    linear-gradient(145deg, #030806, #111);
  color: var(--cream);
  overflow-x: hidden;
}

button {
  border: 0;
  border-radius: 8px;
  background: #f4f4f4;
  color: #232323;
  cursor: pointer;
  font-weight: 800;
  min-height: 42px;
  padding: 0 14px;
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.game-shell {
  min-height: 100vh;
  padding: 0;
}

.table-wrap {
  display: grid;
  gap: 0;
  margin: 0 auto;
  max-width: 520px;
  min-height: 100vh;
  overflow: hidden;
  width: 100vw;
}

.top-bar {
  align-items: center;
  display: flex;
  justify-content: center;
  background: transparent;
  border-bottom: 0;
  gap: 10px;
  height: 50px;
  left: 50%;
  padding: 10px;
  position: fixed;
  top: 10px;
  transform: translateX(-50%);
  z-index: 8;
}

.toolbar-button {
  align-items: center;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  color: #fff;
  display: inline-flex;
  font-size: 2rem;
  font-weight: 400;
  height: 42px;
  justify-content: center;
  line-height: 1;
  min-height: 0;
  padding: 0;
  width: 42px;
}

.toolbar-button.toolbar-text {
  font-size: 0.78rem;
  font-weight: 900;
  height: 42px;
  letter-spacing: 0;
  width: 62px;
}

.player-rail {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.eyeline,
.label {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 3px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.45rem;
  line-height: 1.1;
}

h2 {
  font-size: 1rem;
}

.table {
  background:
    radial-gradient(ellipse at center, rgba(255, 255, 255, 0.08), transparent 34%),
    radial-gradient(ellipse at center, rgba(53, 196, 92, 0.22), transparent 55%),
    linear-gradient(180deg, var(--felt), var(--felt-dark));
  border: 10px solid var(--wood-light);
  border-radius: 999px 999px 92px 92px / 210px 210px 80px 80px;
  width: 100%;
  box-shadow:
    inset 0 24px 70px rgba(0, 0, 0, 0.16),
    inset 0 -20px 30px rgba(0, 0, 0, 0.18);
  height: calc(100vh - 14px);
  min-height: 700px;
  overflow: hidden;
  padding: 74px 20px 20px;
  position: relative;
}

.table::before {
  border: 2px solid rgba(216, 180, 95, 0.28);
  border-radius: 50%;
  clip-path: none;
  content: "";
  height: 360px;
  left: 50%;
  opacity: 1;
  pointer-events: none;
  position: absolute;
  top: 44%;
  transform: translate(-50%, -50%);
  width: 340px;
}

.opponent {
  align-items: center;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.86);
  display: flex;
  flex-direction: column;
  font-size: 0.7rem;
  font-weight: 800;
  gap: 5px;
  padding: 7px 10px;
  position: absolute;
}

.opponent-top {
  left: 50%;
  top: 142px;
  transform: translateX(-50%);
}

.opponent-left {
  left: 52px;
  top: 44%;
  transform: none;
}

.opponent-right {
  right: 52px;
  top: 44%;
  transform: none;
}

.opponent-left .mini-hand,
.opponent-right .mini-hand {
  flex-direction: column;
}

.opponent-left .card-back,
.opponent-right .card-back {
  width: 42px;
  height: 26px;
  transform: none;
  transform-origin: center;
}

.dealer-chip {
  align-items: center;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.95), transparent 18%),
    linear-gradient(180deg, #f8f1d7, #d8b45f);
  border: 3px solid #2b1609;
  border-radius: 999px;
  color: #1b1008;
  display: none;
  font-size: 0.72rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  position: absolute;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  width: 76px;
  z-index: 6;
}

.dealer-chip.active {
  display: flex;
}

.table .dealer-chip {
  width: max-content;
  min-width: 52px;
  height: auto;
  min-height: 26px;
  padding: 3px 8px;
  border-width: 2px;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  pointer-events: none;
}

@media (max-width: 600px) {
  .table .dealer-chip {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 8px;
    font-size: 20px;
  }
}

.dealer-upcard {
  position: absolute;
  width: 98px;
  height: 144px;
  z-index: 4;
  pointer-events: none;
}

.dealer-upcard[hidden] { display: none; }
.dealer-upcard > .card,
.dealer-upcard > .card-back {
  display: block;
  width: 100%;
  height: 100%;
}

.dealer-chip-p1 {
  left: 34px;
  top: 53%;
}

.dealer-chip-p2 {
  bottom: 268px;
  left: 50%;
  transform: translateX(-50%);
}

.dealer-chip-p3 {
  right: 34px;
  top: 53%;
  transform: none;
}

.dealer-chip-p4 {
  left: 50%;
  top: 156px;
  transform: translateX(-50%);
}

.maker-chip {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: #1c1c1c;
  display: none;
  font-size: 2.7rem;
  font-weight: 900;
  height: auto;
  justify-content: center;
  position: absolute;
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.78),
    0 0 5px rgba(255, 255, 255, 0.82);
  width: auto;
  z-index: 7;
}

.maker-chip.active {
  display: flex;
}

.maker-chip.red {
  color: #bd2f2f;
}

.maker-chip-p1 {
  left: 76px;
  top: 46%;
}

.maker-chip-p2 {
  bottom: 212px;
  left: 50%;
  transform: translateX(-50%);
}

.maker-chip-p3 {
  right: 76px;
  top: 46%;
}

.maker-chip-p4 {
  left: 50%;
  top: 178px;
  transform: translateX(-50%);
}

.mini-hand {
  display: flex;
  gap: 3px;
}

.card-back {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 30%),
    repeating-linear-gradient(45deg, #c5c5c5 0 2px, #9f9f9f 2px 4px);
  border: 1px solid #222;
  border-radius: 3px;
  height: 42px;
  width: 26px;
}

.status-panel,
.score-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  position: absolute;
}

.bidding-panel {
  background: rgba(2, 14, 8, 0.94);
  border: 1px solid rgba(216, 180, 95, 0.44);
  border-radius: 14px;
  bottom: 22px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  display: grid;
  gap: 8px;
  left: 22px;
  min-width: 0;
  padding: 10px 12px 12px;
  position: absolute;
  right: 22px;
  text-align: center;
  top: auto;
  transform: none;
  z-index: 4;
}

.bidding-panel[hidden] {
  display: none;
}

.bid-upcard {
  display: flex;
  justify-content: center;
  left: 50%;
  min-height: 0;
  pointer-events: none;
  position: absolute;
  top: -264px;
  transform: translateX(-50%) scale(1.55) rotate(-4deg);
  transform-origin: center;
}

.bid-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.alone-choice {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 12px;
  font-size: 14px;
  white-space: nowrap;
}

.bid-speech {
  position: absolute;
  z-index: 20;
  padding: 9px 14px;
  border-radius: 8px;
  background: white;
  color: #111;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 3px 9px #0005;
  pointer-events: none;
}

.bid-speech::after {
  content: "";
  position: absolute;
  left: calc(50% - 7px);
  bottom: -9px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid white;
}

.bid-speech-top::after {
  top: -9px;
  bottom: auto;
  border-top: 0;
  border-bottom: 10px solid white;
}

.alone-choice input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.bid-controls button {
  flex: 1;
  font-size: 1.22rem;
  min-height: 48px;
  padding: 0 16px;
}

.bid-controls button.suit-choice {
  font-size: 2.4rem;
  min-width: 74px;
  padding: 0;
}

.bid-controls button.red-suit {
  color: #e11f2b;
}

.status-panel {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  bottom: auto;
  display: none;
  gap: 6px;
  left: 16px;
  padding: 7px 10px;
  text-align: center;
  top: 172px;
  transform: none;
  z-index: 5;
}

.score-panel {
  background: rgba(0, 0, 0, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  left: 50%;
  min-width: 278px;
  padding: 9px 18px;
  right: auto;
  top: 68px;
  transform: translateX(-50%);
}

.score-panel div {
  display: grid;
  justify-items: center;
}

.score-panel strong {
  font-size: 1.75rem;
  font-weight: 400;
  line-height: 1.1;
}

.score-panel .label {
  color: #fff;
  font-size: 0.78rem;
  font-weight: 400;
  text-transform: none;
}

.trick-dots {
  display: flex;
  gap: 7px;
  height: 10px;
  justify-content: center;
  margin-top: 4px;
}

.trick-dot {
  background: #fff;
  border: 1px solid #111;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  height: 10px;
  width: 10px;
}

.trick-banner {
  align-items: center;
  background: transparent;
  border-radius: 0;
  color: #fff;
  display: flex;
  font-size: 1.1rem;
  font-weight: 400;
  left: 50%;
  line-height: 1;
  padding: 0;
  position: absolute;
  right: auto;
  text-align: center;
  top: 220px;
  transform: translateX(-50%);
  width: calc(100% - 40px);
  justify-content: center;
  line-height: 1.25;
  z-index: 5;
}

.trick-banner[hidden] {
  display: none;
}

.trick-banner .pickup-preview-card {
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.42);
  height: 128px;
  transform: rotate(-4deg);
  width: 88px;
}

.trick-zone {
  height: 340px;
  left: 50%;
  position: absolute;
  top: 52%;
  transform: translate(-50%, -50%);
  width: 300px;
}

.played-slot {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 90px;
  min-width: 66px;
  position: absolute;
}

.p1 {
  left: 0;
  top: 128px;
}

.p2 {
  bottom: 0;
  left: 112px;
}

.p3 {
  right: 0;
  top: 128px;
}

.p4 {
  left: 112px;
  top: 0;
}

.card {
  background: #fff;
  border: 2px solid #050505;
  border-radius: 10px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
  color: var(--black);
  height: 122px;
  overflow: hidden;
  padding: 0;
  position: relative;
  width: 84px;
}

button.card {
  cursor: pointer;
  font-family: inherit;
  min-height: 0;
  padding: 0;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

button.card.legal {
  outline: 3px solid rgba(255, 255, 255, 0.95);
  outline-offset: -2px;
}

button.card.legal:hover {
  box-shadow: 0 12px 24px rgba(214, 175, 92, 0.3);
}

button.card.discard-choice {
  outline: 3px solid rgba(216, 180, 95, 0.96);
  outline-offset: -2px;
}

button.card.discard-choice:hover {
  box-shadow: 0 14px 24px rgba(216, 180, 95, 0.36);
}

button.card.illegal {
  cursor: not-allowed;
}

/* Visual companion to the accessible result summary; never blocks table controls. */
.hand-feedback {
  position: absolute;
  inset: 43% 12% auto;
  z-index: 6;
  text-align: center;
  pointer-events: none;
  color: #f4f7f5;
  animation: hand-feedback-fade 3s ease-out both;
}
.hand-feedback strong { display: block; font: 700 40px/1.15 Georgia, serif; }
.hand-feedback span { display: block; margin-top: 12px; font-size: 26px; font-weight: 700; }
.hand-feedback.is-win { color: #f1d77c; text-shadow: 0 0 18px #e8c56c55; }
.hand-feedback.is-match { animation: none; }
@keyframes hand-feedback-fade {
  0% { opacity: 0; }
  15%, 80% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hand-feedback { animation: none; }
}

button.card:disabled,
button.card.illegal {
  opacity: 1;
}

.card.red {
  color: var(--red);
}

.card-face {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.corner {
  align-items: center;
  display: grid;
  font-weight: 900;
  justify-items: center;
  line-height: 0.88;
  position: absolute;
  z-index: 2;
}

.corner-top {
  left: 7px;
  top: 7px;
}

.corner-bottom {
  bottom: 7px;
  right: 7px;
  transform: rotate(180deg);
}

.card .rank {
  font-size: 1.85rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.85;
}

.corner-suit {
  font-size: 1.05rem;
  line-height: 0.8;
}

.card-center {
  inset: 28px 18px;
  position: absolute;
}

.pip {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
  position: absolute;
  transform: translate(-50%, -50%);
}

.pip-center {
  font-size: 3rem;
  left: 50%;
  top: 50%;
}

.pip-top-left {
  left: 30%;
  top: 12%;
}

.pip-top-right {
  left: 70%;
  top: 12%;
}

.pip-upper-left {
  left: 30%;
  top: 34%;
}

.pip-upper-right {
  left: 70%;
  top: 34%;
}

.pip-mid-left {
  left: 30%;
  top: 50%;
}

.pip-mid-right {
  left: 70%;
  top: 50%;
}

.pip-lower-left {
  left: 30%;
  top: 66%;
}

.pip-lower-right {
  left: 70%;
  top: 66%;
}

.pip-bottom-left {
  left: 30%;
  top: 88%;
  transform: translate(-50%, -50%) rotate(180deg);
}

.pip-bottom-right {
  left: 70%;
  top: 88%;
  transform: translate(-50%, -50%) rotate(180deg);
}

.face-art {
  align-items: center;
  border: 2px solid rgba(28, 43, 132, 0.72);
  display: grid;
  font-size: 1.65rem;
  font-weight: 900;
  gap: 2px;
  inset: 0;
  justify-items: center;
  line-height: 1;
  position: absolute;
}

.previous-trick-card {
  left: 50%;
  opacity: 1;
  overflow: hidden;
  position: absolute;
  top: 50%;
}

.previous-trick-card .rank {
  font-size: 2.05rem;
}

.trick-fan .played-slot {
  bottom: auto;
  left: 50%;
  min-height: 250px;
  min-width: 300px;
  right: auto;
  top: 48%;
  transform: translate(-50%, -50%);
}

.trick-fan .played-slot:not(.p2) {
  display: none;
}

.trick-fan .p2 {
  height: 260px;
  width: 330px;
}

.trick-fan .previous-trick-card {
  width: 94px;
  height: 142px;
  transform: translate(calc(-50% + var(--fan-x)), calc(-50% + var(--fan-y))) rotate(var(--fan-angle));
}

.trick-fan .previous-trick-card.winning-card {
  outline: 3px solid rgba(216, 180, 95, 0.96);
  outline-offset: -4px;
}

.player-rail {
  align-items: center;
  background: rgba(0, 0, 0, 0.52);
  border: 1px solid rgba(216, 180, 95, 0.34);
  border-radius: 999px;
  bottom: 172px;
  justify-content: center;
  left: 22px;
  min-height: 0;
  padding: 10px 16px;
  position: absolute;
  right: 22px;
  z-index: 4;
}

.player-rail > div {
  display: none;
}

.action-hint {
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  max-width: none;
  text-align: center;
}

.player-hand {
  bottom: 22px;
  display: flex;
  gap: 4px;
  justify-content: center;
  left: 14px;
  position: absolute;
  right: 14px;
}

.is-bidding .player-rail {
  display: none;
}

.is-bidding .status-panel {
  display: none;
}

.is-bidding .dealer-chip-p2 {
  bottom: 346px;
}

.is-discarding .dealer-chip-p2 {
  bottom: 292px;
}

.is-bidding .player-hand {
  bottom: 136px;
}

.is-discarding .player-hand {
  bottom: 82px;
}

.player-hand .card {
  height: clamp(136px, 38vw, 162px);
  width: clamp(72px, 20vw, 86px);
}

.player-hand .card:nth-child(1) {
  transform: rotate(-9deg) translateY(12px);
}

.player-hand .card:nth-child(2) {
  transform: rotate(-4deg) translateY(3px);
}

.player-hand .card:nth-child(4) {
  transform: rotate(4deg) translateY(3px);
}

.player-hand .card:nth-child(5) {
  transform: rotate(9deg) translateY(12px);
}

.hand-log {
  display: none;
}

.terms-drawer {
  background: rgba(0, 0, 0, 0.58);
  inset: 0;
  padding: 24px 16px;
  position: fixed;
  z-index: 20;
}

.terms-drawer[hidden] {
  display: none;
}

.terms-card {
  background: #071007;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  gap: 14px;
  margin: 0 auto;
  height: calc(100vh - 48px);
  max-width: 430px;
  overflow: hidden;
  padding: 16px;
}

.terms-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.terms-header h2 {
  font-size: 1.35rem;
}

.terms-header button {
  min-height: 40px;
}

.terms-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

.term-item {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  padding: 10px 12px;
}

.term-item h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}

.term-item p {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.9rem;
  line-height: 1.35;
}

#log {
  color: var(--muted);
  display: grid;
  font-size: 0.86rem;
  gap: 7px;
  line-height: 1.35;
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
}

@media (max-width: 390px) {
  .dealer-chip-p2,
  .is-bidding .dealer-chip-p2,
  .is-discarding .dealer-chip-p2 {
    bottom: 206px;
    left: 8px;
    transform: none;
  }

  .maker-chip-p2 {
    bottom: 206px;
    left: auto;
    right: 12px;
    transform: none;
  }

  .dealer-chip-p4 {
    top: 178px;
    left: calc(50% + 65px);
  }
  .game-shell {
    padding: 0;
    width: 100vw;
  }

  .table-wrap {
    margin: 0;
    max-width: 100vw;
    width: 100vw;
  }

  .table {
    height: calc(100vh - 14px);
    min-height: 690px;
    padding: 14px;
  }

  button {
    font-size: 0.76rem;
    padding: 0 12px;
  }

  .bid-upcard {
    top: -252px;
    transform: translateX(-50%) scale(1.42) rotate(-4deg);
  }

  .is-bidding .player-rail {
    display: none;
  }

  .is-bidding .player-hand {
    bottom: 146px;
  }
}

@media (orientation: landscape) {
  .game-shell {
    padding: 0;
  }

  .table-wrap {
    max-width: none;
    width: 100vw;
  }

  .top-bar {
    height: 56px;
    padding: 8px;
    position: fixed;
    z-index: 5;
  }

  .toolbar-button {
    background: rgba(0, 0, 0, 0.46);
    border: 1px solid rgba(216, 180, 95, 0.38);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    height: 40px;
    left: auto;
    position: static;
    top: auto;
    width: 44px;
  }

  .table {
    background:
      radial-gradient(ellipse at center, rgba(216, 180, 95, 0.12), transparent 38%),
      radial-gradient(ellipse at center, #198a45 0%, #0d5c31 52%, #020402 86%);
    border: 12px solid var(--wood-light);
    border-radius: 999px / 310px;
    box-shadow:
      inset 0 0 120px rgba(0, 0, 0, 0.72),
      0 12px 50px rgba(0, 0, 0, 0.5);
    height: calc(100vh - 20px);
    min-height: 520px;
    margin: 10px auto;
    max-width: 1180px;
    padding: 0;
  }

  .score-panel {
    background: rgba(0, 0, 0, 0.5);
    gap: 18px;
    justify-content: center;
    left: 50%;
    right: auto;
    top: 72px;
    transform: translateX(-50%);
  }

  .score-panel div {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    height: auto;
    min-width: 86px;
    place-content: center;
  }

  .score-panel div:nth-child(2) {
    background: transparent;
    border-left: 0;
    border-radius: 0;
  }

  .score-panel .label {
    display: block;
  }

  .score-panel strong {
    color: #fff;
    font-size: 2rem;
    font-weight: 900;
    text-shadow: none;
  }

  .trick-banner {
    left: 50%;
    max-width: 360px;
    right: auto;
    top: 164px;
    transform: translateX(-50%);
    width: max-content;
  }

  .opponent {
    color: rgba(0, 0, 0, 0.65);
    font-size: 1.45rem;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  .opponent-top {
    top: 136px;
  }

  .opponent-left {
    left: 16%;
    top: 46%;
    transform: none;
  }

  .opponent-right {
    right: 16%;
    top: 46%;
    transform: none;
  }

  .opponent-left .mini-hand,
  .opponent-right .mini-hand {
    flex-direction: column;
  }

  .mini-hand {
    transform: rotate(6deg);
  }

  .status-panel {
    display: none;
    left: 94px;
    top: 84px;
  }

  .status-panel .label {
    display: block;
  }

  .status-panel strong {
    color: #fff;
    font-size: 0.86rem;
    font-weight: 900;
  }

  .dealer-chip {
    height: 34px;
    width: 76px;
  }

  .dealer-chip-p1 {
    left: 16%;
    top: 48%;
  }

  .dealer-chip-p2 {
    bottom: 37%;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  .dealer-chip-p3 {
    right: 16%;
    top: 48%;
  }

  .dealer-chip-p4 {
    left: 50%;
    top: 172px;
    transform: translateX(-50%);
  }

  .maker-chip-p1 {
    left: 19%;
    top: 44%;
  }

  .maker-chip-p2 {
    bottom: 31%;
  }

  .maker-chip-p3 {
    right: 19%;
    top: 44%;
  }

  .maker-chip-p4 {
    top: 154px;
  }

  .trick-zone {
    height: 250px;
    top: 43%;
    width: 420px;
  }

  .p1 {
    left: 30px;
    top: 100px;
  }

  .p2 {
    bottom: 0;
    left: 170px;
  }

  .p3 {
    right: 30px;
    top: 100px;
  }

  .p4 {
    left: 170px;
    top: 0;
  }

  .card {
    height: 128px;
    width: 92px;
  }

  .player-hand {
    bottom: -38px;
    gap: 0;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 540px;
  }

  .player-hand .card {
    height: 178px;
    width: 116px;
  }

  .player-hand .card:nth-child(1) {
    transform: rotate(-17deg) translateY(38px);
  }

  .player-hand .card:nth-child(2) {
    transform: rotate(-8deg) translateY(12px);
  }

  .player-hand .card:nth-child(3) {
    transform: rotate(0deg);
  }

  .player-hand .card:nth-child(4) {
    transform: rotate(8deg) translateY(12px);
  }

  .player-hand .card:nth-child(5) {
    transform: rotate(17deg) translateY(38px);
  }

  .player-rail {
    display: none;
  }

  .action-hint {
    color: rgba(255, 255, 255, 0.88);
  }

  .bidding-panel {
    background: rgba(3, 18, 12, 0.94);
    border: 1px solid rgba(216, 180, 95, 0.52);
    border-radius: 14px;
    bottom: 22px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    left: 50%;
    max-width: 410px;
    padding: 10px 12px 12px;
    right: auto;
    top: auto;
    transform: translateX(-50%);
    width: 38vw;
  }

  .bidding-panel .label {
    display: none;
  }

  #bid-title {
    color: #fff;
    display: block;
    font-size: 1.15rem;
    line-height: 1.1;
    margin-bottom: 14px;
    text-shadow: 0 2px 2px #000;
  }

  .bid-upcard {
    display: none;
  }

  .bid-controls {
    display: flex;
    gap: 14px;
  }

  .bid-controls button {
    background: #f4f4f4;
    border-radius: 8px;
    color: #232323;
    font-size: 1.05rem;
    min-height: 46px;
    text-shadow: 0 2px 2px rgba(0, 0, 0, 0.48);
  }

  .bid-controls button + button {
    background: #f4f4f4;
    color: #4b4b4b;
    text-shadow: none;
  }

  .bid-controls button.suit-choice {
    font-size: 2.3rem;
  }

  .is-bidding .player-hand {
    bottom: -44px;
  }

  .terms-card {
    max-width: 620px;
  }
}

/* Square table and start screen. */
[hidden] { display: none !important; }
body { background: #111817; }
.start-screen { --lobby-bg:#101917; --lobby-field:#182620; --lobby-line:#41554b; --lobby-text:#f3f5f1; --lobby-muted:#abbdb3; --lobby-gold:#e7c66e; min-height:100svh; display:flex; flex-direction:column; align-items:center; padding:0 36px 28px; gap:0; background:var(--lobby-bg); color:var(--lobby-text); }
.start-logo { width:224px; max-width:100%; margin:26px 0 36px; }
.start-logo img { display: block; width: 100%; height: auto; border-radius: 50%; }
.account-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; }
#account-dialog, #guest-transfer-dialog { background:#14251f; color:#f5f7f6; border:1px solid #71867a; border-radius:8px; padding:20px; width:min(440px,calc(100% - 24px)); max-height:calc(100dvh - 32px); overflow:auto; margin:auto; }
#guest-transfer-dialog { box-sizing:border-box; }
#guest-transfer-dialog h2 { margin:0 0 12px; font-size:20px; }
#guest-transfer-message { margin:0 0 20px; line-height:1.5; }
#account-dialog::backdrop, #guest-transfer-dialog::backdrop { background:#0009; }
#account-title { font-size:22px; }
#account-note, #account-message { line-height:1.5; overflow-wrap:anywhere; }
#account-form, #account-code-form { display:grid; gap:12px; }
#account-dialog [hidden], #guest-transfer-dialog [hidden] { display:none !important; }
#account-dialog input { box-sizing:border-box; width:100%; min-width:0; font-size:16px; padding:10px; }
#account-code { text-align:center; font-size:24px; font-variant-numeric:tabular-nums; }
#account-dialog button, #guest-transfer-dialog button { min-height:44px; }
#learning-panel { width: 100%; padding: 12px 0; border-bottom: 1px solid #55655d; }
#learning-progress { margin: 0 0 8px; font-size: 13px; color: #f1d77c; }
#learning-title { font-size: 20px; line-height: 1.3; margin: 0 0 8px; }
#learning-text { font-size: 16px; line-height: 1.5; margin: 0 0 12px; }
.learning-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.learning-actions button { min-height: 44px; }
#lesson-next, #learning-hint { background: #e7c66e; }
#exit-learning { margin-left: auto; background: transparent; color: #fff; border: 1px solid #687875; }
body .table .learning-target { outline: 4px solid #f1d77c; outline-offset: 4px; }
#leaderboards, #player-stats { background: #14251f; color: #f5f7f6; border: 1px solid #71867a; border-radius: 8px; padding: 20px; width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow: auto; margin: auto; }
#player-stats { width: min(360px, calc(100% - 24px)); }
#leaderboards::backdrop, #player-stats::backdrop { background: #0009; }
.standings-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.standings-header h2 { font-size: 22px; overflow-wrap: anywhere; }
.standings-header button, .standings-pages button { width: 44px; height: 44px; flex-shrink: 0; font-size: 24px; padding: 0; }
.standings-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.standings-filters label, #player-stats label { display: grid; gap: 6px; min-width: 0; }
.standings-filters select, #player-stats select { width: 100%; min-width: 0; height: 44px; color: white; background: #24392f; border: 1px solid #71867a; border-radius: 4px; padding: 6px; font: inherit; }
.standings-minimum, #player-stats-category { color: #c7d2cb; font-size: 13px; margin: 14px 0; }
.standings-scroll { overflow-x: auto; }
.standings-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.standings-table th, .standings-table td { padding: 12px 5px; text-align: right; border-bottom: 1px solid #43574b; }
.standings-table th:nth-child(2), .standings-table td:nth-child(2) { text-align: left; min-width: 110px; }
.standings-player { display: inline; background: none; border: 0; color: #f1d67c; font: inherit; text-align: left; padding: 6px 0; min-height: 44px; cursor: pointer; overflow-wrap: anywhere; }
.standings-player:hover, .standings-player:focus-visible { text-decoration: underline; }
.standings-pages { display: flex; align-items: center; justify-content: space-between; margin: 16px 0; }
.standings-own { padding: 10px 0; border-top: 1px solid #43574b; }
.standings-own p { font-size: 13px; }
#standings-mine h3 { font-size: 16px; }
.stat-grid { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px 16px; font-size: 14px; padding-top: 10px; }
.stat-grid dd { margin: 0; font-weight: bold; }
#player-hover-stats { position: fixed; z-index: 10; width: min(300px, calc(100vw - 16px)); background: #f5f7f6; color: #17251e; border: 1px solid #71867a; border-radius: 6px; padding: 14px; box-shadow: 0 8px 24px #0007; }
#player-hover-stats p { font-size: 12px; margin-top: 6px; }
.start-screen button { background:var(--lobby-gold); min-height:48px; border-radius:6px; font:700 16px/1.3 Arial,Helvetica,sans-serif; padding:12px 18px; transition:background-color 140ms,border-color 140ms; }
.start-screen button:hover:not(:disabled) { background:#f3d88f; }
.start-screen :is(button,input,select):focus-visible { outline:2px solid var(--lobby-gold); outline-offset:4px; }
.lobby-header { display:flex; align-items:center; justify-content:space-between; gap:24px; width:100%; max-width:1280px; min-height:84px; border-bottom:1px solid var(--lobby-line); }
.lobby-wordmark { font:700 28px/1.15 Georgia,'Times New Roman',serif; }
.start-screen .account-actions { gap:14px; align-items:center; flex-wrap:nowrap; }
.start-screen .account-actions button { background:transparent; border:1px solid transparent; color:var(--lobby-text); font-size:14px; }
.start-screen .account-actions #save-account { border-color:#ac914e; color:var(--lobby-gold); }
.start-screen .account-actions button:hover { background:#24332b; }
.lobby-layout { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); align-items:start; width:100%; max-width:1080px; }
.lobby-layout h2 { font-size:28px; line-height:1.2; margin:0 0 16px; font-weight:700; }
.start-screen #start-form { display:grid; gap:12px; width:100%; min-width:0; padding-right:48px; }
.lobby-name-heading { display:flex; align-items:baseline; flex-wrap:wrap; justify-content:space-between; gap:8px 16px; }
.lobby-name-heading label, .start-screen legend, .start-screen .room-entry > label, .start-screen #room-bot-settings label, .start-screen #join-room-form > label { color:var(--lobby-muted); font-size:14px; font-weight:600; }
.lobby-name-heading #guest-status { margin:0; max-width:100%; font-size:12px; line-height:1.5; overflow-wrap:anywhere; }
.start-screen #player-name, .start-screen #room-code, .start-screen .room-entry select { width:100%; min-width:0; height:48px; border:1px solid #52665b; border-radius:6px; background:var(--lobby-field); color:var(--lobby-text); padding:10px 12px; font:400 16px/1.4 Arial,Helvetica,sans-serif; }
.start-screen input::placeholder { color:#85978d; opacity:1; }
.start-screen fieldset.lobby-difficulty { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; min-width:0; border:0; padding:12px 0 6px; margin:4px 0 2px; }
.start-screen .lobby-difficulty label { display:flex; justify-content:center; align-items:center; gap:7px; min-width:0; min-height:48px; border:1px solid var(--lobby-line); border-radius:6px; padding:6px; font-size:14px; cursor:pointer; transition:background-color 140ms,border-color 140ms; }
.lobby-difficulty input { accent-color:var(--lobby-gold); width:15px; height:15px; margin:0; flex-shrink:0; }
.start-screen .lobby-difficulty label:has(input:checked) { border-color:var(--lobby-gold); color:var(--lobby-gold); background:#302d20; }
.start-screen .lobby-difficulty label:has(input:focus-visible) { outline:2px solid var(--lobby-gold); outline-offset:3px; }
.start-screen #resume-room { color:var(--lobby-gold); background:transparent; border:1px solid #ac914e; }
.start-screen #resume-room:hover { background:#302d20; }
.start-screen .room-entry { display:grid; gap:12px; width:100%; min-width:0; padding:0 0 0 48px; border-top:0; border-left:1px solid var(--lobby-line); }
.start-screen #create-room { background:transparent; color:var(--lobby-gold); border:1px solid #81968b; margin-top:2px; }
.start-screen #create-room:hover { background:#24332b; }
.start-screen #join-room-form { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px 12px; width:100%; min-width:0; margin-top:12px; padding-top:22px; border-top:1px solid var(--lobby-line); }
.start-screen #join-room-form > label { grid-column:1 / -1; }
.start-screen #join-room-form button { min-width:120px; }
.lobby-links { display:flex; justify-content:center; align-items:center; width:100%; max-width:1080px; border-top:1px solid var(--lobby-line); margin-top:36px; padding-top:18px; gap:24px; }
.start-screen .lobby-links button { background:transparent; color:var(--lobby-text); font-size:15px; font-weight:500; padding:8px 16px; }
.start-screen .lobby-links button+button { border-left:1px solid var(--lobby-line); border-radius:0; }
.start-screen .lobby-links button:hover { color:var(--lobby-gold); background:transparent; }
.start-screen #save-warning { width:100%; max-width:1080px; color:var(--lobby-gold); font-size:14px; margin:12px 0 0; }
@media (min-width:1100px) and (min-height:950px) { .start-logo { width:264px; margin-top:28px; margin-bottom:40px; } }
@media (max-width:900px) {
  .start-screen { padding-right:24px; padding-left:24px; }
  .start-screen #start-form { padding-right:28px; }
  .start-screen .room-entry { padding-left:28px; }
  .lobby-layout h2 { font-size:24px; }
  .start-screen .lobby-difficulty label { font-size:12px; gap:4px; }
  .lobby-difficulty input { width:13px; height:13px; }
}
@media (max-width:700px) {
  .start-screen { padding:0 20px 24px; }
  .lobby-header { min-height:74px; gap:12px; }
  .lobby-wordmark { font-size:20px; }
  .start-screen .account-actions { gap:2px; }
  .start-screen .account-actions button { font-size:12px; padding:8px 10px; min-height:44px; }
  .start-logo { width:148px; margin:22px 0 28px; }
  .lobby-layout { grid-template-columns:minmax(0,1fr); max-width:440px; gap:32px; }
  .start-screen #start-form { padding-right:0; }
  .lobby-layout h2 { font-size:24px; margin-bottom:10px; }
  .start-screen .room-entry { padding:28px 0 0; border-left:0; border-top:1px solid var(--lobby-line); }
  .start-screen .lobby-difficulty label { font-size:13px; gap:6px; }
  .start-screen .lobby-difficulty input { position:absolute; opacity:0; width:1px; height:1px; }
  .start-screen .lobby-difficulty span { white-space:nowrap; }
  .lobby-links { max-width:440px; margin-top:28px; gap:14px; }
}
@media (max-width:360px) {
  .start-screen { padding-right:16px; padding-left:16px; }
  .lobby-wordmark { font-size:18px; max-width:94px; }
  .start-screen .account-actions button { padding-right:8px; padding-left:8px; }
  .start-screen .lobby-difficulty label { font-size:12px; gap:4px; padding:4px; }
}
@media (prefers-reduced-motion:reduce) { .start-screen button,.start-screen .lobby-difficulty label { transition:none; } }
body .table-wrap { display: flex; flex-direction: column; align-items: center; width: calc(100% - 24px); max-width: 700px; min-height: 0; overflow: visible; padding-bottom: 24px; }
body .top-bar { position: static; transform: none; width: 100%; height: auto; min-height: 64px; padding: 8px 0; justify-content: flex-start; }
#session-name { flex: 1; font-size: 14px; overflow-wrap: anywhere; }
body .score-panel { position: static; transform: none; display: flex; justify-content: space-around; width: 100%; padding: 8px 0 14px; background: transparent; }
body .table { width: 700px; height: 700px; min-height: 700px; flex-shrink: 0; border: 8px solid #52605a; border-radius: 8px; padding: 0; background: #155638; }
body .table::before { display: none; }
body .opponent { font-size: 12px; color: white; text-shadow: none; }
body .opponent-top { top: 20px; }
body .opponent-left { left: 20px; top: 40%; }
body .opponent-right { right: 20px; top: 40%; }
body .mini-hand { transform: none; }
body .table .player-hand { bottom: 20px; left: 50%; transform: translateX(-50%); width: 480px; }
body .table .player-hand .card { width: 80px; height: 120px; }
body .trick-zone { top: 44%; }
body .trick-banner { top: 120px; font-size: 16px; }
body .player-rail { position: static; transform: none; width: 100%; margin: 12px 0; padding: 10px; min-height: 42px; font-size: 14px; background: transparent; }
body .bidding-panel { position: static; transform: none; width: 100%; padding: 12px; border: 1px solid #55655d; border-radius: 8px; background: #202d29; }
body .bid-controls { display: flex; gap: 8px; margin-top: 10px; }
body .bid-controls button { flex: 1; width: auto; margin: 0; font-size: 18px; min-height: 44px; padding: 8px; }
body .maker-chip-p2 { bottom: 150px; }
body .table .maker-chip {
  width: 32px;
  height: 36px;
  font-size: 30px;
  line-height: 1;
  text-shadow: none;
  pointer-events: none;
}
body .table .maker-chip-p1 { left: 28px; right: auto; top: calc(40% - 40px); bottom: auto; transform: none; }
body .table .maker-chip-p3 { right: 28px; left: auto; top: calc(40% - 40px); bottom: auto; transform: none; }
body .table .maker-chip-p4 { left: calc(50% - 116px); right: auto; top: 24px; bottom: auto; transform: none; }
body .table .maker-chip-p2 { left: 50%; right: auto; top: auto; bottom: 198px; transform: translateX(-50%); }
body .game-shell { display: block; width: 100%; padding: 0; }
body .table-wrap { margin: 0 auto; }
body .score-panel { border: 0; border-radius: 0; }
body .table .player-hand { width: 610px; }
body .table .player-hand .card { width: 104px; height: 156px; }
@media (max-width: 600px) {
  body .opponent { font-size: 20px; }
  body .table .player-hand .card { width: 114px; height: 170px; }
}

/* Clean Lobby: home-only styling; the table and its controls retain their theme. */
.start-screen.clean-lobby { --lobby-bg:#fff; --lobby-field:#fff; --lobby-line:#d4dad7; --lobby-text:#202824; --lobby-muted:#536159; --lobby-gold:#b38a36; color-scheme:light; padding:0 0 40px; background:#fff; color:#202824; font-family:Arial,Helvetica,sans-serif; }
.clean-lobby .lobby-header { max-width:none; min-height:170px; background:#003c2a; color:#fff; padding:24px max(28px,calc((100% - 1200px)/2)); border:0; gap:24px; }
.clean-lobby .lobby-brand { display:flex; align-items:center; gap:22px; flex-shrink:0; }
.clean-lobby .lobby-brand img { width:132px; height:132px; border-radius:50%; display:block; }
.clean-lobby .lobby-wordmark { font:700 38px/1.15 Georgia,'Times New Roman',serif; margin:0; letter-spacing:0; }
.clean-lobby .header-explore { display:flex; margin-left:auto; gap:4px; }
.clean-lobby .header-explore button, .clean-lobby .account-actions button { background:transparent; color:#fff; border:1px solid transparent; font-size:14px; padding:10px 12px; min-height:44px; white-space:nowrap; }
.clean-lobby .account-actions { gap:10px; }
.clean-lobby .account-actions #save-account { border-color:#d4b465; color:#f4d88e; }
.clean-lobby .account-actions #sign-in, .clean-lobby .account-actions #sign-out { border-color:#93aba1; }
.clean-lobby .header-explore button:hover, .clean-lobby .account-actions button:hover { background:#17543f; }
.clean-lobby .lobby-layout { display:grid; grid-template-columns:minmax(0,1fr); max-width:620px; width:calc(100% - 40px); gap:24px; padding-top:28px; }
.clean-lobby .lobby-tabs { display:grid; grid-template-columns:1fr 1fr; border-bottom:1px solid var(--lobby-line); margin-bottom:4px; }
.clean-lobby .lobby-tabs button { border:0; border-bottom:3px solid transparent; border-radius:0; background:transparent; color:#454f49; font-size:19px; font-weight:400; padding:12px 4px 16px; }
.clean-lobby .lobby-tabs button[aria-selected="true"] { border-bottom-color:#0b5538; color:#064a31; font-weight:700; }
.clean-lobby .lobby-tabs button:hover { background:#f1f6f3; }
.clean-lobby .lobby-identity { display:grid; gap:10px; }
.clean-lobby .lobby-name-heading label, .clean-lobby legend, .clean-lobby .room-entry > label, .clean-lobby #room-bot-settings label, .clean-lobby #join-room-form > label { color:#303934; font-size:15px; font-weight:600; }
.clean-lobby #guest-status { color:#69756e; }
.clean-lobby #player-name, .clean-lobby #room-code, .clean-lobby .room-entry select { height:52px; background:#fff; color:#28312b; border-color:#b5bfb9; padding:12px 14px; }
.clean-lobby #start-form { padding:0; gap:14px; }
.clean-lobby fieldset.lobby-difficulty { gap:0; padding:12px 0 0; margin:0 0 10px; }
.clean-lobby .lobby-difficulty label { border-radius:0; border-right:0; font-size:15px; font-weight:400; min-height:52px; position:relative; }
.clean-lobby .lobby-difficulty label:first-of-type { border-radius:6px 0 0 6px; }
.clean-lobby .lobby-difficulty label:last-of-type { border-right:1px solid var(--lobby-line); border-radius:0 6px 6px 0; }
.clean-lobby .lobby-difficulty input { position:absolute; opacity:0; width:1px; height:1px; }
.clean-lobby .lobby-difficulty label:has(input:checked) { background:#095336; color:#fff; border-color:#095336; }
.clean-lobby .lobby-difficulty span { white-space:nowrap; }
.clean-lobby button { box-shadow:none; letter-spacing:0; }
.clean-lobby #start-form > button[type="submit"], .clean-lobby #create-room { background:#095336; color:#fff; border:1px solid #095336; min-height:54px; font-size:19px; margin:0; }
.clean-lobby #start-form > button[type="submit"]:hover, .clean-lobby #create-room:hover { background:#003c28; }
.clean-lobby #resume-room { background:#fff; color:#095336; border:1px solid #095336; min-height:50px; }
.clean-lobby #resume-room:hover { background:#edf5ef; }
.clean-lobby .room-entry { padding:0; border:0; gap:12px; }
.clean-lobby #join-room-form { margin:4px 0 0; padding-top:24px; gap:10px 14px; }
.clean-lobby #join-room-form button { background:#edf0ee; color:#243c2f; border:1px solid #d4dad7; min-width:140px; }
.clean-lobby #join-room-form button:hover { background:#dde7e0; }
.clean-lobby .lobby-links { max-width:620px; width:calc(100% - 40px); margin-top:30px; padding-top:24px; gap:0; }
.clean-lobby .lobby-links button { flex:1; display:flex; justify-content:center; align-items:center; gap:18px; min-height:64px; font-size:17px; font-weight:700; color:#064a31; padding:8px; }
.clean-lobby .lobby-links svg { width:42px; height:42px; flex-shrink:0; color:#ba913d; }
.clean-lobby .lobby-links button:hover { background:#f1f6f3; color:#003c28; }
.clean-lobby #save-warning { max-width:620px; width:calc(100% - 40px); color:#854a17; }
.clean-lobby :is(button,input,select):focus-visible, .clean-lobby .lobby-difficulty label:has(input:focus-visible) { outline:3px solid #ba913d; outline-offset:3px; }
body:has(.clean-lobby:not([hidden])) { background:#fff; }
body:has(.clean-lobby:not([hidden])) .room-message { color:#883b27; }
@media(max-width:1100px) {
  .clean-lobby .header-explore { display:none; }
  .clean-lobby .lobby-header { justify-content:space-between; }
}
@media(max-width:740px) {
  .clean-lobby .lobby-header { display:grid; grid-template-columns:90px minmax(0,1fr); gap:12px 16px; padding:24px 20px; min-height:164px; }
  .clean-lobby .lobby-brand { display:contents; }
  .clean-lobby .lobby-brand img { width:90px; height:90px; grid-row:1 / 3; }
  .clean-lobby .lobby-wordmark { font-size:26px; max-width:none; align-self:end; white-space:nowrap; }
  .clean-lobby .account-actions { justify-content:flex-start; gap:8px; align-self:start; flex-wrap:wrap; }
  .clean-lobby .account-actions button { font-size:12px; padding:8px 10px; }
  .clean-lobby .lobby-layout { padding-top:12px; gap:22px; }
  .clean-lobby .lobby-tabs button { font-size:17px; }
  .clean-lobby .lobby-difficulty label { font-size:13px; }
  .clean-lobby .lobby-links { padding-top:20px; margin-top:26px; }
  .clean-lobby .lobby-links button { flex-direction:column; gap:10px; font-size:15px; }
  .clean-lobby #join-room-form button { min-width:112px; padding:10px; }
}
@media(max-width:360px) {
  .clean-lobby .lobby-header { grid-template-columns:74px minmax(0,1fr); gap:10px; padding:20px 16px; }
  .clean-lobby .lobby-brand img { width:74px; height:74px; }
  .clean-lobby .lobby-wordmark { font-size:23px; }
  .clean-lobby .account-actions { gap:5px; }
  .clean-lobby .account-actions button { padding:8px; }
}

/* Turn feedback stays outside the played-card area. */
.hand-result { width: 100%; padding: 20px 0 8px; display: grid; gap: 16px; }
.hand-result h2 { font-size: 22px; line-height: 1.3; margin: 0 0 10px; color: #fff; }
.hand-result p { font-size: 16px; line-height: 1.5; margin: 4px 0; color: #c9d6cf; overflow-wrap: anywhere; }
.hand-result #hand-result-points, .hand-result #hand-result-game { color: #f1d77c; font-weight: 700; }
#room-bot-settings:not([hidden]) { display: grid; gap: 12px; }
#room-code { height: 44px; padding: 8px; font: inherit; text-transform: uppercase; width: 100%; }
.room-lobby { max-width: 520px; margin: 40px auto; padding: 24px; display: grid; gap: 16px; }
.room-lobby h1 { font-size: 28px; }
.room-lobby ol { padding-left: 24px; line-height: 2; overflow-wrap: anywhere; }
.room-lobby button { min-height: 44px; }
.room-message { max-width: 700px; margin: 12px auto; padding: 12px; color: #f1d77c; text-align: center; }
.game-preferences { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; width: 100%; padding: 0 0 8px; font-size: 14px; }
.game-preferences label:first-child { margin-right: auto; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.game-preferences select { font: inherit; min-height: 44px; padding: 6px 10px; color: #fff; background: #202d29; border: 1px solid #687875; border-radius: 6px; }
#new-game-dialog { max-width: 420px; width: calc(100% - 32px); padding: 24px; color: #fff; background: #202d29; border: 1px solid #687875; border-radius: 8px; }
#new-game-dialog::backdrop { background: rgb(0 0 0 / 65%); }
#new-game-dialog h2 { font-size: 22px; margin: 0 0 12px; }
#new-game-dialog p { font-size: 16px; line-height: 1.5; margin-bottom: 20px; }
#new-game-dialog form { display: flex; flex-wrap: wrap; gap: 12px; }
#new-game-dialog button { flex: 1; min-height: 44px; padding: 10px; }
#new-game-dialog button[value="start"] { background: #e7c66e; color: #171d19; }
body .opponent > span { display: block; max-width: 120px; overflow-wrap: anywhere; }
body .opponent.is-computer > span { max-width: none; white-space: nowrap; }
@media (max-width: 600px) {
  body .opponent.is-computer { font-size: 18px; }
}
.deal-button { width: 100%; min-height: 48px; margin: 12px 0 8px; background: #e7c66e; color: #171d19; font-size: 16px; }
body .opponent.is-active-turn {
  outline: 3px solid #f1d77c;
  outline-offset: 4px;
  background: #093e29;
}
body .player-rail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  border: 0;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  text-align: center;
}
body .player-rail > div { display: block; }
body .player-rail .label { display: none; }
body #turn-status { font-size: 18px; color: #fff; }
body .action-hint { font-size: 14px; line-height: 1.4; text-shadow: none; color: #c9d6cf; }
body .player-rail.is-active-turn { border-bottom-color: #f1d77c; }
body .player-rail.is-active-turn #turn-status { color: #f1d77c; }
body:not(.is-discarding) #trick-banner {
  position: static;
  transform: none;
  width: 100%;
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 1.4;
}
body.is-bidding .player-rail { display: flex; }
@media (min-width: 601px) {
  body .table .player-hand { bottom: 65px; }
  body .table .maker-chip-p2 { bottom: 243px; }
}
body button:focus-visible, body input:focus-visible { outline: 3px solid #f1d77c; outline-offset: 4px; }
body .bid-controls { flex-wrap: wrap; }
body .bid-controls button { min-width: 60px; text-shadow: none; }
@media (max-width: 600px) {
  body .table .player-hand { width: 650px; bottom: 24px; gap: 0; }
  body .table .player-hand .card { width: 126px; height: 188px; flex-shrink: 0; }
  body .trick-fan .previous-trick-card { width: 110px; height: 166px; }
  body .table .maker-chip-p2 { bottom: 232px; }
  body .trick-banner { font-size: 24px; }
  body .table .maker-chip { font-size: 38px; }
  body .top-bar { gap: 8px; }
  body #session-name { font-size: 13px; }
  body .toolbar-button { min-height: 44px; }
  body .bidding-panel { max-width: none; }
}

/* Keep the mobile controls close to the table without reducing touch targets. */
@media (max-width: 600px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body .top-bar { min-height: 48px; padding: 2px 0; }
  body .game-preferences { padding-bottom: 0; gap: 8px; }
  body .score-panel { padding: 2px 0 6px; }
  body .score-panel strong { font-size: 24px; }
  body .player-rail { min-height: 36px; margin: 4px 0; padding: 4px; gap: 2px; }
  body.is-bidding .player-rail .action-hint { display: none; }
  body .bidding-panel { padding: 8px; }
  body #bid-title { margin-bottom: 0; font-size: 15px; }
  body .bid-controls { margin-top: 6px; }
  body .table-wrap { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
#human-maker-seat:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  margin-top: 6px;
  font-size: 14px;
}
#human-maker-seat #maker-chip-p2 {
  position: static;
  inset: auto;
  transform: none;
  width: 28px;
  height: 32px;
  font-size: 28px;
  line-height: 1;
  z-index: auto;
}
.table-emblem {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40%;
  aspect-ratio: 1.015;
  border-radius: 50%;
  overflow: hidden;
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
}
.table-emblem img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 113%;
  max-width: none;
  height: auto;
  transform: translate(-47.24%, -49.38%);
}

/* Desktop keeps decisions beside the table and the next deal below it. */
@media (min-width: 900px) {
  body .table-wrap.desktop-table-layout {
    display: grid;
    grid-template-columns: var(--desktop-table-size) minmax(280px, 320px);
    grid-template-rows: auto var(--desktop-table-size) auto;
    align-items: start;
    justify-content: center;
    gap: 12px 20px;
    max-width: 1060px;
    padding-bottom: 12px;
  }
  .desktop-table-layout > .top-bar { grid-column: 1 / -1; min-height: 48px; padding: 2px 0; }
  .desktop-table-layout > .table { grid-column: 1; grid-row: 2; }
  .desktop-table-layout > .deal-button { grid-column: 1; grid-row: 3; margin: 0; }
  .desktop-game-controls { grid-column: 2; grid-row: 2 / 4; width: 100%; max-height: calc(100dvh - 76px); overflow-y: auto; padding: 0 8px 8px; }
  body .desktop-game-controls .score-panel { padding: 8px 0 12px; }
  body .desktop-game-controls .player-rail { margin: 8px 0; padding: 8px 0; }
  body .desktop-game-controls .bidding-panel { max-width: none; }
  .desktop-game-controls .hand-result { padding-top: 12px; }
  .desktop-game-controls .hand-result h2 { font-size: 20px; }
}

/* Table refresh: retain the existing card geometry and responsive controls. */
.game-shell { --table-gold: #efcb76; --table-line: #64735a; }
body:has(.game-shell:not([hidden])) { background: #0b1714; }
body .game-shell .top-bar { border-bottom: 1px solid #394a40; padding: 8px 0; gap: 12px; }
.game-brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.game-brand img { flex-shrink: 0; width: 52px; height: 52px; border-radius: 50%; }
.game-brand > div { min-width: 0; }
.game-brand strong { display: block; font: 700 24px/1.15 Georgia, serif; color: #f5e5b6; }
.game-brand #session-name { display: block; margin-top: 4px; color: #becdc5; font-size: 12px; line-height: 1.35; }
body .game-shell .toolbar-button { border-radius: 8px; border-color: #657364; background: #13271f; box-shadow: none; flex-shrink: 0; color: #f5e5b6; }
body .game-shell .game-preferences { padding: 6px 0; color: #becdc5; }
.game-shell input[type="checkbox"] { accent-color: #e7c66e; }
body .game-shell .score-panel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; min-width: 0; background: #10281f; border: 1px solid var(--table-line); border-radius: 8px; padding: 10px 0; margin-bottom: 12px; }
.game-shell .score-panel > div { min-width: 0; align-content: start; }
.game-shell .score-panel > div + div { border-left: 1px solid #495d49; }
body .game-shell .score-panel strong { color: var(--table-gold); font-size: 28px; font-weight: 700; line-height: 1.15; }
body .game-shell .score-panel .label { color: #dce6df; font-size: 12px; margin-bottom: 4px; }
body .game-shell #table-trump { color: #f6f8f7; font-size: 30px; }
body .game-shell #table-trump.red { color: #ff6373; }
.game-shell .trick-dot { width: 7px; height: 7px; background: #efcb76; border: none; box-shadow: none; }
.game-shell .trick-dots { gap: 5px; height: 7px; }
body .game-shell .table { border: 4px solid #7e8256; border-radius: 8px; background: radial-gradient(ellipse at 50% 42%, #206447, #104831 75%); box-shadow: inset 0 0 65px #001c1c66, 0 12px 28px #0003; }
.game-shell .table-emblem { opacity: .22; width: 43%; }
body .game-shell .opponent { border: 1px solid #ffffff18; border-radius: 8px; background: #073e2ba6; padding: 8px 10px; color: #f3f6f4; }
body .game-shell .opponent.is-active-turn {
  outline: 2px solid #efcb76;
  outline-offset: 3px;
  background: #164f36;
  box-shadow: 0 0 12px #efcb7633;
}
body .game-shell #player-hand.is-active-turn .card {
  outline: 2px solid #efcb76;
  outline-offset: 1px;
  box-shadow: 0 0 12px #efcb7644;
}
body .game-shell #player-hand .card.learning-target {
  outline: 4px solid #f1d77c;
  outline-offset: 4px;
  box-shadow: 0 0 0 3px #f1d77c;
}
body .game-shell #player-hand .card:focus-visible {
  outline: 3px dashed #ffffff;
  outline-offset: 6px;
}
.game-shell .card-back { background: repeating-linear-gradient(45deg, #e6e9f033 0 1px, transparent 1px 5px), repeating-linear-gradient(-45deg, #e6e9f033 0 1px, #294c70 1px 5px); border: 2px solid #e3e8e5; box-shadow: inset 0 0 0 2px #294c70; }
.game-shell .card { border-color: #19392c; box-shadow: 0 5px 10px #00150b66; }
body .game-shell .table .dealer-chip { background: #efcb76; border-color: #6d572d; color: #19251c; box-shadow: 0 2px 5px #0004; }
body .game-shell .deal-button { background: linear-gradient(#f4d783, #dfb655); color: #10271e; border: 1px solid #f4d783; min-height: 48px; font-size: 18px; }
.game-shell .deal-button:disabled { background: #243b30; color: #a8b6a9; border-color: #46584a; opacity: 1; }
body .game-shell .bidding-panel { background: #132c22; border-color: #52674f; box-shadow: none; }
.game-shell .bid-controls button { background: #f5f7f5; color: #18372a; }
.game-shell .bid-controls button.red-suit { color: #bd2f2f; }
.game-shell .bid-controls button:last-child:not(.suit-choice) { background: #efcb76; }
.game-shell .hand-result { border-top: 1px solid #435749; margin-top: 12px; }
.game-shell .hand-result h2 { color: #f1d77c; font-family: Georgia, serif; }
@media (min-width: 900px) {
  body .game-shell .top-bar { padding: 4px 0; }
  .game-brand img { width: 44px; height: 44px; }
  body .game-shell .desktop-game-controls { border-left: 1px solid #394a40; padding: 0 0 12px 20px; }
  body .game-shell .desktop-table-layout { column-gap: 24px; padding-bottom: 8px; }
}
@media (max-width: 600px) {
  .game-brand { gap: 8px; }
  .game-brand img { width: 42px; height: 42px; }
  .game-brand strong { font-size: 20px; }
  .game-brand #session-name { font-size: 11px; }
  body .game-shell .top-bar { gap: 8px; }
  body .game-shell .score-panel { padding: 6px 0; margin-bottom: 8px; }
  body .game-shell .score-panel strong { font-size: 25px; }
  body .game-shell .toolbar-button.toolbar-text { width: 50px; }
  body .game-shell .game-preferences { padding: 0; }
}
@media (max-width: 360px) {
  .game-brand strong { font-size: 17px; }
  .game-brand img { width: 34px; height: 34px; }
}

/* Compact game header; visual turn feedback remains on the seats and legal cards. */
body .game-shell .top-bar { flex-wrap: wrap; }
body .game-shell .top-bar .game-preferences { width: auto; padding: 0; gap: 8px; }
body .game-shell .top-bar .score-panel { flex-basis: 100%; margin: 0; }
.trump-caller { font-size: 11px; line-height: 1.3; color: #dce6df; overflow-wrap: anywhere; text-align: center; padding: 0 4px; }
body .game-shell .sound-control { position: relative; display: grid; place-items: center; margin: 0; width: 44px; height: 44px; border: 1px solid #657364; border-radius: 8px; color: #f5e5b6; cursor: pointer; }
.sound-control input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.sound-control svg { width: 22px; height: 22px; pointer-events: none; }
.sound-control .sound-off, .sound-control:has(input:not(:checked)) .sound-on { display: none; }
.sound-control:has(input:not(:checked)) .sound-off { display: block; }
.sound-control:has(input:focus-visible) { outline: 3px solid #f1d77c; outline-offset: 2px; }
body .game-shell #human-maker-seat { display: none; }
body .game-shell .player-rail { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); border: 0; }
body .game-shell .table-wrap { width: calc(100% - 8px); }
.desktop-game-controls:not(:has(#bidding-panel:not([hidden]), #learning-panel:not([hidden]), #hand-result:not([hidden]))) { border-left: 0 !important; }
@media (max-width: 899px) {
  body .game-shell .table { height: max(700px, calc((100dvh - 210px) / var(--table-scale, 1))); }
  body:has(#learning-panel:not([hidden])) .game-shell .table { height: max(700px, calc((100dvh - 340px) / var(--table-scale, 1))); }
}

/* Regular play keeps the hand at the table edge and bids above the felt. */
body:not(:has(#learning-panel:not([hidden]))) .game-shell .table .player-hand { bottom: -76px; }
.bid-popup-card:empty { display: none; }
.bid-popup-card { display: flex; justify-content: center; }
.bid-popup-card .card { width: 64px; height: 96px; }
body:not(:has(#learning-panel:not([hidden]))) .game-shell .bidding-panel:not([hidden]) {
  position: fixed; z-index: 30; left: 50%; right: auto; top: max(148px, 27dvh); bottom: auto;
  transform: translateX(-50%); width: min(340px, calc(100vw - 32px)); max-width: none;
  padding: 14px; border: 2px solid #d8b45f; border-radius: 8px;
  background: #10271ef5; box-shadow: 0 12px 40px #0008;
}
body:not(:has(#learning-panel:not([hidden]))):has(#bidding-panel:not([hidden])) #bid-upcard { visibility: hidden; }
body:not(:has(#learning-panel:not([hidden]))) .bidding-panel .alone-choice { margin: 8px 0 0; display: flex; justify-content: center; }
body:not(:has(#learning-panel:not([hidden]))) .bidding-panel .bid-controls { flex-wrap: wrap; }
@media (max-height: 500px) and (orientation: landscape) {
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .bidding-panel:not([hidden]) {
    top: 76px; width: 350px; padding: 8px; grid-template-columns: 64px 1fr; gap: 4px 10px;
  }
  .bid-popup-card { grid-row: 1 / 3; }
  body .game-shell .bidding-panel .bid-controls { margin-top: 4px; }
}
@media (max-width: 600px) {
  body .game-shell .top-bar { gap: 6px; padding: 4px 0; }
  .game-shell .game-brand { flex: 1; gap: 0; }
  .game-shell .game-brand img { width: 36px; height: 36px; }
  .game-shell .game-brand > div { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  body .game-shell .toolbar-button.toolbar-text { width: 44px; }
  body .game-shell .toolbar-button { width: 36px; }
  body .game-shell .sound-control { width: 36px; }
  body .game-shell .game-preferences select { width: 86px; padding: 6px; font-size: 13px; }
  body .game-shell .top-bar .game-preferences { gap: 6px; }
  body .game-shell .top-bar .score-panel { padding: 4px 0; }
  body .game-shell .deal-button { margin: 6px 0; }
}

/* Regular tables use one centered column; lessons retain their instruction rail. */
/* Cropped cards must not scroll the felt when a browser focuses their buttons. */
body:not(:has(#learning-panel:not([hidden]))) .game-shell .table {
  overflow: clip;
  container: regular-table / size;
}
@media (min-width: 900px) {
  body:not(:has(#learning-panel:not([hidden]))) .table-wrap.desktop-table-layout {
    grid-template-columns: var(--desktop-table-size);
    max-width: var(--desktop-table-size);
  }
  body:not(:has(#learning-panel:not([hidden]))) .desktop-game-controls {
    grid-column: 1;
    grid-row: 4;
    max-height: none;
    overflow: visible;
    border: 0;
    padding: 0;
  }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .table .player-hand { bottom: -24px; }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .bidding-panel:not([hidden]) { top: max(180px, 36dvh); }
}
body:not(:has(#learning-panel:not([hidden]))) .bid-popup-card .card { width: 96px; height: 144px; }
@media (max-width: 899px) {
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .table .player-hand {
    width: 640px;
    gap: 0;
    bottom: -60px;
  }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .table .player-hand .card {
    width: 164px;
    height: 246px;
    flex-shrink: 0;
  }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .table .player-hand .card + .card { margin-left: -45px; }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .trick-fan .previous-trick-card { width: 154px; height: 232px; }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .trick-fan .played-slot { top: 58%; }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .trick-zone { top: 55%; }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell #trick-banner .card { width: 154px; height: 232px; }
  /* Keep the full trick between the top seat and hand on shorter felt areas. */
  @container regular-table (max-height: 900px) {
    body:not(:has(#learning-panel:not([hidden]))) .game-shell .trick-zone { top: calc(50% - 50px); }
    body:not(:has(#learning-panel:not([hidden]))) .game-shell .trick-fan .played-slot { top: 50%; }
    body:not(:has(#learning-panel:not([hidden]))) .game-shell .trick-fan .previous-trick-card {
      transform: translate(calc(-50% + var(--fan-x)), calc(-50% + var(--fan-y) * .63)) rotate(var(--fan-angle));
    }
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  body:not(:has(#learning-panel:not([hidden]))) .bid-popup-card .card { width: 72px; height: 108px; }
  body:not(:has(#learning-panel:not([hidden]))) .game-shell .bidding-panel:not([hidden]) { grid-template-columns: 72px 1fr; }
}
