:root {
  color-scheme: dark;
  --felt: #11513f;
  --felt-deep: #062922;
  --rail: #2c1f16;
  --rail-light: #6b4426;
  --brass: #e7c46f;
  --paper: #fff9ed;
  --paper-edge: #d6c3a2;
  --ink: #17130e;
  --red: #b11f2b;
  --black: #161411;
  --mist: rgba(244, 234, 219, 0.78);
  --line: rgba(244, 234, 219, 0.18);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--paper);
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.04), transparent 36%),
    radial-gradient(circle at 20% 10%, rgba(215, 181, 109, 0.22), transparent 24rem),
    radial-gradient(circle at 80% 80%, rgba(179, 38, 45, 0.18), transparent 22rem),
    linear-gradient(140deg, #061d1c, #0a3b31 48%, #1f1915);
}

.effects-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid rgba(231, 196, 111, 0.7);
  background: linear-gradient(#f7dda0, #d7b459);
  color: #1c140c;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
  transform: none;
  box-shadow: none;
}

.secondary-button {
  background: rgba(244, 234, 219, 0.08);
  color: var(--paper);
}

.ghost-button {
  background: transparent;
  color: var(--brass);
  box-shadow: none;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: rgba(2, 20, 18, 0.58);
  color: var(--paper);
  padding: 0 12px;
  outline: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--mist);
  font-size: 0.86rem;
}

.app-shell {
  width: min(640px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0;
}

.table-panel {
  border: 10px solid var(--rail);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 0 80px rgba(0, 0, 0, 0.2);
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.045), transparent 44%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--felt);
  background-size: 22px 22px;
  padding: clamp(16px, 2vw, 26px);
  position: relative;
}

.table-panel::before {
  content: "";
  position: absolute;
  inset: -10px;
  border: 1px solid rgba(231, 196, 111, 0.28);
  pointer-events: none;
}

.topbar,
.table-state,
.hand-heading,
.action-row,
.field-row,
.command-row,
.join-row {
  display: flex;
  gap: 14px;
}

.topbar {
  justify-content: space-between;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--brass);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  font-size: clamp(2.5rem, 7vw, 5.6rem);
  font-weight: 400;
}

h2 {
  font-size: 1.35rem;
}

.room-badge,
.turn-card,
.lobby,
.players-panel,
.hand-panel,
.pile-zone {
  border: 1px solid var(--line);
  background: rgba(3, 28, 25, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.room-badge {
  min-width: 120px;
  padding: 12px 14px;
  text-align: right;
  background: rgba(0, 0, 0, 0.22);
}

.room-badge span {
  display: block;
  color: var(--mist);
  font-size: 0.78rem;
}

.room-badge strong {
  display: block;
  font-size: 1.7rem;
  letter-spacing: 0.08em;
}

.lobby {
  margin-top: 18px;
  padding: 16px;
}

.lobby.hidden {
  display: none;
}

.field-row {
  align-items: end;
  flex-wrap: wrap;
}

.field-row label:first-child {
  flex: 1 1 190px;
}

.field-row .setup-small {
  flex: 0 0 112px;
  width: 120px;
}

.command-row {
  margin-top: 12px;
  flex-wrap: wrap;
}

.join-row {
  flex: 1;
  min-width: 240px;
}

.join-row input {
  text-transform: uppercase;
}

.share-line {
  margin: 12px 0 0;
  color: var(--mist);
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.table-state {
  margin-top: 18px;
  align-items: stretch;
}

.pile-zone {
  flex: 1;
  min-height: 174px;
  padding: 16px;
  position: relative;
}

.pile-zone::after {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px dashed rgba(231, 196, 111, 0.2);
  pointer-events: none;
}

.turn-card {
  width: min(320px, 36%);
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.turn-card strong {
  font-size: 1.75rem;
  color: #fff5dc;
}

.turn-card p {
  margin: 0;
  color: var(--mist);
  line-height: 1.4;
}

.players-panel {
  margin-top: 18px;
  padding: 12px;
}

.hand-panel {
  margin-top: 18px;
  padding: 16px;
}

.players {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.player-chip {
  flex: 0 0 min(180px, 48%);
  border: 1px solid var(--line);
  padding: 9px 10px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08));
  min-height: 64px;
  position: relative;
}

.player-chip.active {
  border-color: var(--brass);
  box-shadow: inset 0 0 0 1px rgba(215, 181, 109, 0.28), 0 0 0 2px rgba(231, 196, 111, 0.08);
  animation: activeSeat 1.8s ease-in-out infinite;
}

.player-chip.active::after {
  content: "ON TURN";
  position: absolute;
  right: 10px;
  top: 8px;
  color: var(--brass);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
}

.player-chip.passed {
  opacity: 0.55;
}

.player-chip strong,
.player-chip span {
  display: block;
}

.player-chip span {
  color: var(--mist);
  font-size: 0.78rem;
  margin-top: 3px;
}

.hand-heading {
  justify-content: space-between;
  align-items: center;
}

.preview-pill {
  border: 1px solid rgba(215, 181, 109, 0.42);
  color: var(--brass);
  padding: 9px 12px;
  min-width: 150px;
  text-align: center;
  background: rgba(0, 0, 0, 0.18);
}

.card-row,
.hand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.empty-pile {
  color: var(--mist);
  min-height: 88px;
  display: grid;
  place-items: center start;
}

.pile-label {
  margin-top: 12px;
  color: var(--mist);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 10px;
}

.pile-play-label {
  color: #fff5dc;
}

.pile-played-by {
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.card {
  width: 74px;
  height: 104px;
  border: 1px solid var(--paper-edge);
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.94), transparent 34%),
    linear-gradient(145deg, #fffdf6, var(--paper) 58%, #eadfc9);
  color: var(--black);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.28), inset 0 0 0 3px rgba(255, 255, 255, 0.62);
  user-select: none;
  padding: 0;
  transform-origin: bottom center;
  animation: dealIn 260ms ease both;
}

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

.card.selectable {
  cursor: pointer;
}

.card.selectable:hover {
  transform: translateY(-6px) rotate(-1deg);
}

.card.selected {
  transform: translateY(-14px);
  outline: 3px solid var(--brass);
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.34), 0 0 0 5px rgba(231, 196, 111, 0.18), inset 0 0 0 3px rgba(255, 255, 255, 0.62);
  animation: selectedPulse 900ms ease-in-out infinite alternate;
}

.card .corner {
  position: absolute;
  display: grid;
  justify-items: center;
  line-height: 0.9;
  font-weight: 800;
  font-size: 0.95rem;
}

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

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

.card .pip {
  font-size: 2.35rem;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.65));
}

.card[data-id^="10"] .corner {
  font-size: 0.82rem;
}

/* ---- Fanned hand ---- */
.hand.is-fanned {
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0;
  --overlap: 30px;
  padding: 46px 8px 10px;
  min-height: 168px;
}

.hand.is-fanned .card {
  margin-left: calc(var(--overlap) * -1);
  transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg));
  transition: transform 200ms cubic-bezier(0.2, 0.7, 0.3, 1), box-shadow 200ms ease;
  animation: none;
}

.hand.is-fanned .card:first-child {
  margin-left: 0;
}

.hand.is-fanned .card.dealing {
  animation: handDealIn 320ms cubic-bezier(0.2, 0.7, 0.3, 1) var(--deal-delay, 0ms) backwards;
}

.hand.is-fanned .card.selectable:hover {
  transform: translateY(-22px) rotate(0deg) scale(1.05);
  z-index: 60 !important;
  box-shadow: 0 26px 36px rgba(0, 0, 0, 0.42), inset 0 0 0 3px rgba(255, 255, 255, 0.62);
}

.hand.is-fanned .card.selected {
  transform: translateY(-32px) rotate(0deg);
  z-index: 58 !important;
}

/* ---- Pile: overlapping drop-in ---- */
.pile-zone .card-row:not(.empty-pile) {
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0;
  padding-top: 6px;
  min-height: 112px;
  align-items: flex-start;
}

.card.pile-card {
  margin-left: -18px;
  transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg));
  animation: pileDrop 340ms cubic-bezier(0.18, 0.74, 0.3, 1.08) var(--drop-delay, 0ms) backwards;
}

.card.pile-card:first-child {
  margin-left: 0;
}

@keyframes handDealIn {
  from {
    opacity: 0;
    transform: translateY(30px) rotate(0deg);
  }
  to {
    opacity: 1;
    transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg));
  }
}

@keyframes pileDrop {
  from {
    opacity: 0;
    transform: translateY(-34px) rotate(var(--rot, 0deg)) scale(1.08);
  }
  to {
    opacity: 1;
    transform: translateY(var(--lift, 0px)) rotate(var(--rot, 0deg)) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .hand.is-fanned .card.dealing,
  .card.pile-card {
    animation: none !important;
  }
}

.action-row {
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
}

#passTurn {
  margin-left: auto;
}

.auto-pass-control {
  flex: 1 0 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--mist);
  font-size: 0.78rem;
  line-height: 1.15;
  cursor: pointer;
}

.auto-pass-control input {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex: 0 0 18px;
  margin: 0;
  accent-color: var(--brass);
  cursor: pointer;
}

.auto-pass-control span {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 7px;
}

.auto-pass-control strong {
  color: #fff5dc;
  font-weight: 500;
}

.auto-pass-control small {
  color: var(--mist);
  font-size: 0.68rem;
}

.auto-pass-control.disabled {
  opacity: 0.52;
  cursor: default;
}

.effect-lab {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.effect-lab[hidden] {
  display: none;
}

.effect-lab button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.86rem;
}

.table-effect {
  position: fixed;
  left: 50%;
  top: 16%;
  min-width: min(78vw, 360px);
  border: 2px solid rgba(255, 249, 237, 0.72);
  background: rgba(4, 28, 24, 0.88);
  color: var(--paper);
  text-align: center;
  padding: 18px 22px;
  transform: translateX(-50%);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48), inset 0 0 0 1px rgba(231, 196, 111, 0.3);
  animation: effectToast 1800ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.table-effect strong {
  display: block;
  font-size: clamp(2.15rem, 9vw, 5rem);
  line-height: 0.9;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table-effect span {
  display: block;
  margin-top: 8px;
  color: var(--mist);
  font-size: 1rem;
}

.table-effect img {
  display: block;
  width: min(44vw, 156px);
  aspect-ratio: 1;
  object-fit: contain;
  margin: -4px auto 12px;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.42));
  animation: lossImageDrop 620ms cubic-bezier(0.12, 0.76, 0.24, 1.18) both;
}

.table-effect.win {
  border-color: rgba(247, 221, 160, 0.95);
  background:
    linear-gradient(135deg, rgba(247, 221, 160, 0.18), transparent 46%),
    rgba(4, 42, 34, 0.94);
}

.table-effect.win strong {
  color: var(--brass);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3), 0 0 34px rgba(231, 196, 111, 0.34);
}

.table-effect.loss {
  top: 18%;
  border-color: rgba(255, 86, 86, 0.84);
  background:
    linear-gradient(135deg, rgba(177, 31, 43, 0.28), transparent 56%),
    rgba(24, 9, 9, 0.94);
  animation: lossStamp 2200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.table-effect.loss.with-image {
  min-width: min(84vw, 390px);
  padding-top: 14px;
}

.table-effect.loss strong {
  color: #ffeded;
  text-shadow: 0 3px 0 rgba(126, 14, 20, 0.8), 0 0 34px rgba(255, 56, 56, 0.36);
}

.confetti-piece {
  position: fixed;
  top: -16px;
  left: var(--x);
  width: 9px;
  height: 15px;
  background: var(--color);
  border-radius: 1px;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.18);
  animation: confettiFall 1700ms cubic-bezier(0.12, 0.76, 0.52, 1) forwards;
}

.bomb-effect {
  position: fixed;
  left: 50%;
  top: 40%;
  width: 240px;
  height: 240px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  animation: bombShake 1100ms ease-out both;
}

.blast-ring,
.blast-core {
  grid-area: 1 / 1;
}

.blast-ring {
  width: 74px;
  height: 74px;
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(255, 249, 237, 0.98) 0 16%, rgba(247, 221, 160, 0.95) 17% 28%, rgba(229, 65, 41, 0.82) 29% 44%, rgba(115, 25, 15, 0.2) 45% 62%, transparent 63%);
  box-shadow: 0 0 34px rgba(247, 221, 160, 0.72), 0 0 90px rgba(229, 65, 41, 0.56);
  animation: blastRing 1200ms ease-out both;
}

.blast-core {
  color: #fff9ed;
  font-size: clamp(2.1rem, 12vw, 4.6rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-shadow: 0 4px 0 rgba(75, 18, 10, 0.95), 0 0 28px rgba(255, 245, 194, 0.72);
  transform: rotate(-5deg);
  animation: blastText 1200ms ease-out both;
}

.blast-caption {
  position: absolute;
  top: calc(50% + 64px);
  left: 50%;
  width: min(76vw, 360px);
  transform: translateX(-50%);
  color: var(--paper);
  text-align: center;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.72);
  animation: blastCaption 1400ms ease-out both;
}

.blast-spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 26px;
  border-radius: 999px;
  background: linear-gradient(#fff9ed, #f35f35 55%, transparent);
  transform: rotate(var(--angle)) translateY(-12px);
  transform-origin: center bottom;
  animation: blastSpark 950ms ease-out both;
}

@keyframes dealIn {
  from {
    opacity: 0;
    transform: translateY(12px) rotate(-2deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
}

@keyframes selectedPulse {
  from {
    box-shadow: 0 18px 28px rgba(0, 0, 0, 0.34), 0 0 0 5px rgba(231, 196, 111, 0.18), inset 0 0 0 3px rgba(255, 255, 255, 0.62);
  }
  to {
    box-shadow: 0 20px 34px rgba(0, 0, 0, 0.42), 0 0 0 7px rgba(231, 196, 111, 0.28), inset 0 0 0 3px rgba(255, 255, 255, 0.72);
  }
}

@keyframes activeSeat {
  0%,
  100% {
    box-shadow: inset 0 0 0 1px rgba(215, 181, 109, 0.28), 0 0 0 2px rgba(231, 196, 111, 0.08);
  }
  50% {
    box-shadow: inset 0 0 0 1px rgba(215, 181, 109, 0.42), 0 0 0 4px rgba(231, 196, 111, 0.16);
  }
}

@keyframes effectToast {
  0% {
    opacity: 0;
    transform: translate(-50%, -22px) scale(0.82) rotate(-2deg);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.04) rotate(1deg);
  }
  72% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -10px) scale(0.96);
  }
}

@keyframes lossStamp {
  0% {
    opacity: 0;
    transform: translate(-50%, -32px) scale(1.8) rotate(-14deg);
  }
  16% {
    opacity: 1;
    transform: translate(-50%, 0) scale(0.94) rotate(-6deg);
  }
  22%,
  34% {
    transform: translate(calc(-50% - 5px), 0) scale(1) rotate(-6deg);
  }
  28%,
  40% {
    transform: translate(calc(-50% + 5px), 0) scale(1) rotate(-6deg);
  }
  72% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1) rotate(-6deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 16px) scale(0.94) rotate(-6deg);
  }
}

@keyframes lossImageDrop {
  0% {
    opacity: 0;
    transform: translateY(-46px) scale(0.42) rotate(-18deg);
  }
  54% {
    opacity: 1;
    transform: translateY(5px) scale(1.08) rotate(7deg);
  }
  76% {
    transform: translateY(-2px) scale(0.98) rotate(-3deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translate3d(0, -12px, 0) rotate(0deg);
  }
  8% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx), 108vh, 0) rotate(var(--rot));
  }
}

@keyframes bombShake {
  0% {
    filter: brightness(1);
  }
  12%,
  26%,
  40% {
    filter: brightness(1.4);
    transform: translate(calc(-50% - 4px), calc(-50% + 2px));
  }
  19%,
  33% {
    transform: translate(calc(-50% + 5px), calc(-50% - 2px));
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes blastRing {
  0% {
    opacity: 0;
    transform: scale(0.22);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(3.2);
  }
}

@keyframes blastText {
  0% {
    opacity: 0;
    transform: scale(0.36) rotate(-14deg);
  }
  12% {
    opacity: 1;
    transform: scale(1.14) rotate(-5deg);
  }
  72% {
    opacity: 1;
    transform: scale(1) rotate(-5deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.9) rotate(-5deg);
  }
}

@keyframes blastCaption {
  0%,
  18% {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  30%,
  76% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

@keyframes blastSpark {
  0% {
    opacity: 0;
    transform: rotate(var(--angle)) translateY(-12px) scaleY(0.35);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translateY(calc(-1 * var(--distance))) scaleY(0.05);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 16px, 430px);
    padding: 10px 0;
  }

  .table-panel {
    border-width: 6px;
    padding: 10px;
  }

  .topbar,
  .table-state,
  .hand-heading,
  .field-row {
    flex-direction: column;
  }

  .topbar {
    gap: 10px;
    padding-bottom: 10px;
  }

  h1 {
    font-size: 2.65rem;
  }

  .room-badge {
    min-width: 110px;
    align-self: flex-start;
  }

  .lobby,
  .players-panel,
  .pile-zone,
  .turn-card,
  .hand-panel {
    margin-top: 10px;
  }

  .lobby,
  .players-panel,
  .pile-zone,
  .turn-card,
  .hand-panel {
    padding: 12px;
  }

  .players {
    gap: 7px;
  }

  .player-chip {
    flex-basis: 138px;
    min-height: 58px;
    padding: 8px;
  }

  .player-chip strong {
    font-size: 1rem;
    padding-right: 52px;
  }

  .player-chip span {
    font-size: 0.72rem;
  }

  .player-chip.active::after {
    right: 7px;
    top: 7px;
    font-size: 0.52rem;
  }

  .turn-card,
  .field-row .setup-small {
    width: 100%;
    flex-basis: auto;
  }

  .turn-card {
    gap: 7px;
  }

  .turn-card strong {
    font-size: 1.35rem;
  }

  .turn-card p {
    font-size: 0.95rem;
  }

  .pile-zone {
    min-height: 112px;
  }

  .pile-zone::after {
    inset: 14px;
  }

  .empty-pile {
    min-height: 50px;
  }

  .pile-label {
    margin-top: 6px;
  }

  .preview-pill {
    min-width: 0;
    width: 100%;
    padding: 8px;
  }

  .card {
    width: 52px;
    height: 74px;
    border-radius: 5px;
  }

  .card .corner {
    font-size: 0.68rem;
  }

  .card .pip {
    font-size: 1.55rem;
  }

  .hand,
  .card-row {
    gap: 6px;
  }

  .hand {
    margin-top: 10px;
  }

  .hand.is-fanned {
    padding: 36px 4px 8px;
    min-height: 126px;
  }

  .hand.is-fanned .card.selectable:hover {
    transform: translateY(-16px) rotate(0deg) scale(1.05);
  }

  .hand.is-fanned .card.selected {
    transform: translateY(-24px) rotate(0deg);
  }

  .pile-zone .card-row:not(.empty-pile) {
    min-height: 84px;
  }

  .card.pile-card {
    margin-left: -13px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  #playCards {
    grid-column: 1 / -1;
  }

  #passTurn {
    margin-left: 0;
    justify-self: stretch;
  }

  .auto-pass-control {
    grid-column: 1 / -1;
  }

  .table-effect {
    top: 12%;
    min-width: min(86vw, 340px);
    padding: 14px 16px;
  }

  .table-effect img {
    width: min(42vw, 126px);
    margin-bottom: 10px;
  }

  .bomb-effect {
    top: 34%;
    width: 190px;
    height: 190px;
  }

  .blast-caption {
    top: calc(50% + 54px);
    font-size: 0.92rem;
  }
}

/* ============================================================
   Existing table layout: slim header, lobby/invite landing,
   opponents → pile → turn banner → hand. These rules preserve
   Murdah's original felt-table structure and visual language.
   ============================================================ */

:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
}

/* Slim header */
.topbar {
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  gap: 10px;
}

.brand {
  color: var(--brass);
  font-size: 1.5rem;
  letter-spacing: 0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.seat-count {
  color: var(--mist);
  font-size: 0.82rem;
}

.room-chip {
  color: var(--mist);
  font-size: 0.82rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 9px;
  background: rgba(0, 0, 0, 0.2);
}

.room-chip strong {
  color: var(--brass);
  letter-spacing: 0.12em;
  margin-left: 4px;
}

.invite-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brass);
  color: #3a2c0a;
  border: none;
  border-radius: 7px;
  padding: 6px 11px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), filter 140ms var(--ease-out), background 160ms ease;
}

.invite-button:hover {
  filter: brightness(1.05);
}

.invite-button:active {
  transform: scale(0.97);
}

.invite-button.copied {
  background: #57d9b4;
}

.invite-icon-dot {
  font-size: 0.95rem;
}

/* Landing */
.lobby {
  border: none;
  background: none;
  box-shadow: none;
  padding: 0;
  margin: 24px auto 0;
  max-width: 460px;
}

.lobby-create,
.lobby-invite {
  border: 1px solid var(--line);
  background: rgba(3, 28, 25, 0.6);
  border-radius: 12px;
  padding: 22px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.lobby-title {
  font-size: clamp(2.6rem, 7vw, 4rem);
  text-align: center;
}

.lobby-sub {
  color: var(--mist);
  text-align: center;
  margin: 8px 0 20px;
  line-height: 1.45;
}

.computer-upgrade {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 20px;
  padding: 13px 14px;
  border: 1px solid rgba(231, 196, 111, 0.34);
  border-radius: 10px;
  background:
    linear-gradient(115deg, rgba(231, 196, 111, 0.13), transparent 58%),
    rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.computer-upgrade-cards {
  flex: 0 0 58px;
  height: 42px;
  position: relative;
}

.mini-card {
  position: absolute;
  left: 18px;
  top: 3px;
  width: 27px;
  height: 37px;
  display: grid;
  place-items: center;
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  background: linear-gradient(145deg, #fffdf6, var(--paper));
  color: var(--black);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.28);
  transform: rotate(0deg) translateY(-2px);
}

.mini-card:first-child {
  left: 4px;
  transform: rotate(-12deg) translateY(2px);
}

.mini-card:last-child {
  left: 32px;
  transform: rotate(12deg) translateY(2px);
}

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

.computer-upgrade-copy {
  display: grid;
  gap: 3px;
  line-height: 1.25;
}

.computer-upgrade-label {
  color: var(--brass);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.computer-upgrade-copy strong {
  color: #fff5dc;
  font-size: 0.94rem;
  font-weight: 500;
}

.primary-button.block,
.secondary-button.block {
  width: 100%;
}

.ghost-button.block {
  width: 100%;
  margin-top: 12px;
}

.primary-button.block {
  margin-top: 16px;
}

.join-fallback {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.join-fallback span {
  color: var(--mist);
  font-size: 0.85rem;
}

.join-fallback input {
  flex: 1;
  min-width: 90px;
  text-transform: uppercase;
}

.lobby-invite {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.invite-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(231, 196, 111, 0.16);
  border: 1px solid rgba(231, 196, 111, 0.4);
  color: var(--brass);
  display: grid;
  place-items: center;
  font-size: 26px;
}

.invite-eyebrow {
  color: var(--mist);
  margin: 0;
  font-size: 0.85rem;
}

.invite-code {
  color: #fff5dc;
  font-size: 2.4rem;
  letter-spacing: 0.14em;
  font-weight: 500;
  line-height: 1;
}

.invite-name-label {
  width: 100%;
  text-align: left;
}

.invite-sub {
  color: var(--mist);
  font-size: 0.82rem;
  margin: 0;
  line-height: 1.4;
}

/* Table reflow */
.table:not([hidden]) {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.table .pile-zone,
.table .hand-panel {
  margin-top: 0;
}

.opponents {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.opponents-empty {
  color: var(--mist);
  font-size: 0.9rem;
  margin: 4px 0;
}

.opponent {
  flex: 1 1 130px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 180ms var(--ease-out), background 180ms ease;
}

.opponent.active {
  border-color: var(--brass);
  background: rgba(231, 196, 111, 0.1);
  box-shadow: inset 0 0 0 1px rgba(231, 196, 111, 0.3);
}

.opponent.passed {
  opacity: 0.5;
}

.opponent.out {
  opacity: 0.65;
}

.opponent-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.opponent-name {
  color: #fff5dc;
  font-weight: 500;
  font-size: 0.98rem;
}

.opponent-identity {
  min-width: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px 7px;
}

.session-record {
  color: var(--brass);
  font-size: 0.68rem;
  letter-spacing: 0.035em;
  white-space: nowrap;
}

.opponent-status {
  color: var(--mist);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.opponent.active .opponent-status {
  color: var(--brass);
}

.opponent-count {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.opponent-count strong {
  color: var(--brass);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1;
}

.opponent-count span {
  color: var(--mist);
  font-size: 0.74rem;
}

.opponent-count.ready span {
  color: #8fd9bf;
  font-size: 0.84rem;
}

.pile-zone {
  flex: none;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pile-zone .section-label {
  align-self: flex-start;
}

/* Turn banner — single source of truth, static (no looping motion) */
.turn-banner {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  transition: border-color 200ms var(--ease-out), background 200ms ease;
}

.turn-banner strong {
  font-size: 1.4rem;
  color: #fff5dc;
}

.turn-banner span {
  color: var(--mist);
  font-size: 0.9rem;
}

.turn-banner.is-you {
  border-color: var(--brass);
  background: rgba(231, 196, 111, 0.14);
}

.turn-banner.is-you strong {
  color: var(--brass);
}

.play-history {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.play-history[hidden] {
  display: none;
}

.play-history summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  color: var(--paper);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.play-history summary::-webkit-details-marker {
  display: none;
}

.play-history summary::before {
  content: "›";
  color: var(--brass);
  font-size: 1.35rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 160ms var(--ease-out);
}

.play-history[open] summary::before {
  transform: rotate(90deg);
}

.play-history summary:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: -3px;
}

.history-title {
  color: var(--brass);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.history-latest {
  margin-left: auto;
  color: var(--mist);
  font-size: 0.82rem;
  text-align: right;
}

.history-list {
  max-height: 310px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
}

.history-notice,
.history-loading {
  padding: 9px 13px;
  color: var(--mist);
  font-size: 0.78rem;
  line-height: 1.35;
  background: rgba(231, 196, 111, 0.07);
  border-top: 1px solid var(--line);
}

.history-loading {
  list-style: none;
  border-top: 0;
}

.history-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(244, 234, 219, 0.1);
}

.history-item:last-child {
  border-bottom: 0;
}

.history-index {
  color: rgba(244, 234, 219, 0.44);
  font-size: 0.72rem;
  padding-top: 2px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-body {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.history-heading {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.history-heading strong {
  color: #fff5dc;
  font-size: 0.9rem;
  font-weight: 500;
}

.history-heading span {
  color: var(--mist);
  font-size: 0.8rem;
}

.history-reset .history-heading strong,
.history-pass .history-heading span {
  color: rgba(244, 234, 219, 0.58);
}

.history-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.history-card {
  min-width: 28px;
  padding: 3px 5px;
  border: 1px solid var(--paper-edge);
  border-radius: 4px;
  background: var(--paper);
  color: var(--black);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

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

.table-effect.history {
  border-color: rgba(231, 196, 111, 0.82);
  background:
    linear-gradient(135deg, rgba(231, 196, 111, 0.2), transparent 54%),
    rgba(3, 28, 25, 0.96);
}

.table-effect.history strong {
  color: var(--brass);
  font-size: clamp(1.45rem, 6vw, 2.7rem);
}

.room-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-summary {
  border: 1px solid rgba(143, 217, 191, 0.32);
  border-radius: 8px;
  padding: 12px;
  background: rgba(3, 28, 25, 0.74);
}

.summary-body {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.summary-grid div,
.summary-stat {
  border: 1px solid rgba(244, 234, 219, 0.14);
  background: rgba(0, 0, 0, 0.18);
  padding: 8px;
}

.summary-grid span,
.summary-stat span {
  display: block;
  color: var(--mist);
  font-size: 0.74rem;
}

.summary-grid strong,
.summary-stat strong {
  display: block;
  color: var(--brass);
  font-size: 1rem;
}

.summary-highlight {
  margin: 0;
  color: #fff5dc;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* Hand panel heading + actions */
.you-label {
  color: var(--brass);
  font-weight: 500;
  font-size: 0.98rem;
}

.action-row {
  gap: 8px;
  align-items: center;
}

.play-button {
  flex: 1;
}

#passTurn {
  margin-left: 0;
}

/* Press feedback on every control (design-eng: UI should feel it heard you) */
.primary-button,
.secondary-button,
.ghost-button {
  transition: transform 140ms var(--ease-out), filter 140ms var(--ease-out), background 160ms ease;
}

.primary-button:active,
.secondary-button:active,
.ghost-button:active {
  transform: scale(0.97);
}

/* Selected card: static gold lift, no infinite pulse */
.card.selected {
  animation: none;
}

.utility-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}

.utility-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.auto-deal-control,
.last-game-button {
  min-height: 52px;
  border: 1px solid rgba(244, 234, 219, 0.16);
  border-radius: 9px;
  padding: 9px 11px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--mist);
}

.auto-deal-control {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.auto-deal-control input {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex: 0 0 18px;
  margin: 0;
  accent-color: var(--brass);
  cursor: pointer;
}

.auto-deal-control span,
.last-game-button {
  display: grid;
  gap: 2px;
  text-align: left;
}

.auto-deal-control strong,
.last-game-button span {
  color: #fff5dc;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
}

.auto-deal-control small,
.last-game-button small {
  color: var(--mist);
  font-size: 0.68rem;
}

.auto-deal-control.enabled {
  border-color: rgba(143, 217, 191, 0.5);
  background: rgba(15, 79, 62, 0.32);
}

.auto-deal-control.pending {
  border-color: rgba(231, 196, 111, 0.72);
  background: rgba(231, 196, 111, 0.1);
}

.auto-deal-control:has(input:disabled) {
  opacity: 0.64;
  cursor: default;
}

.last-game-button {
  width: 100%;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 140ms var(--ease-out);
}

.last-game-button:hover,
.last-game-button:focus-visible {
  border-color: rgba(231, 196, 111, 0.52);
  background: rgba(231, 196, 111, 0.08);
}

.last-game-button:active {
  transform: scale(0.98);
}

.last-game-dialog {
  width: min(92vw, 620px);
  max-height: min(84vh, 720px);
  border: 1px solid rgba(231, 196, 111, 0.5);
  border-radius: 12px;
  padding: 0;
  background: #062e27;
  color: #fff5dc;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.58);
}

.last-game-dialog::backdrop {
  background: rgba(0, 13, 11, 0.7);
  backdrop-filter: blur(3px);
}

.last-game-dialog-card {
  padding: 18px;
  overflow: auto;
}

.last-game-dialog-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.last-game-dialog-card h2 {
  margin: 2px 0 0;
  color: var(--brass);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

/* Join / info toast */
.table-effect.join {
  background: rgba(3, 28, 25, 0.94);
  border: 1px solid rgba(231, 196, 111, 0.4);
}

.table-effect.join strong {
  color: var(--brass);
}

.table-effect.turn {
  border-color: rgba(231, 196, 111, 0.82);
  background:
    linear-gradient(135deg, rgba(231, 196, 111, 0.2), transparent 54%),
    rgba(3, 28, 25, 0.96);
}

.table-effect.turn strong {
  color: var(--brass);
}

.table-effect.nudge {
  border-color: rgba(143, 217, 191, 0.82);
  background:
    linear-gradient(135deg, rgba(143, 217, 191, 0.18), transparent 54%),
    rgba(3, 28, 25, 0.96);
}

.table-effect.nudge strong {
  color: #8fd9bf;
}

.nudge-button:not([hidden]) {
  border-color: rgba(143, 217, 191, 0.62);
  color: #8fd9bf;
}

/* Table chat and lightweight player emotes */
.players-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-toggle {
  min-height: 34px;
  border: 1px solid rgba(143, 217, 191, 0.34);
  border-radius: 999px;
  padding: 5px 9px 5px 8px;
  background: rgba(3, 28, 25, 0.74);
  color: #cfeee2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 140ms var(--ease-out);
}

.chat-toggle:hover,
.chat-toggle:focus-visible,
.chat-toggle.has-unread {
  border-color: rgba(143, 217, 191, 0.82);
  background: rgba(15, 79, 62, 0.76);
}

.chat-toggle:active {
  transform: scale(0.97);
}

.chat-toggle-icon {
  color: var(--brass);
}

.chat-unread {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f0c75e;
  color: #092d25;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  line-height: 1;
}

.opponent {
  position: relative;
}

.opponent-react {
  position: absolute;
  right: 7px;
  bottom: 6px;
  width: 30px;
  height: 28px;
  border: 1px solid rgba(143, 217, 191, 0.26);
  border-radius: 8px;
  background: rgba(3, 28, 25, 0.7);
  color: #cfeee2;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, transform 130ms var(--ease-out);
}

.opponent-react:hover,
.opponent-react:focus-visible {
  border-color: var(--brass);
  background: rgba(231, 196, 111, 0.16);
}

.opponent-react:active {
  transform: scale(0.92);
}

.opponent:has(.opponent-react) .opponent-count {
  padding-right: 34px;
}

.reaction-tray {
  position: relative;
  border: 1px solid rgba(231, 196, 111, 0.38);
  border-radius: 11px;
  padding: 9px 38px 9px 11px;
  background:
    linear-gradient(110deg, rgba(231, 196, 111, 0.1), transparent 48%),
    rgba(3, 28, 25, 0.92);
  display: flex;
  align-items: center;
  gap: 12px;
}

.reaction-tray-copy {
  min-width: 76px;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.reaction-tray-copy span {
  color: var(--mist);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.reaction-tray-copy strong {
  color: #fff5dc;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reaction-choices {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.reaction-choice {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.055);
  font-size: 1.18rem;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 130ms var(--ease-out);
}

.reaction-choice:hover,
.reaction-choice:focus-visible {
  background: rgba(231, 196, 111, 0.17);
  border-color: rgba(231, 196, 111, 0.7);
  transform: translateY(-2px);
}

.reaction-choice:active {
  transform: scale(0.92);
}

.reaction-close,
.chat-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--mist);
  font: inherit;
  font-size: 1.35rem;
  cursor: pointer;
}

.reaction-close {
  position: absolute;
  top: 9px;
  right: 7px;
}

.chat-scrim {
  position: fixed;
  inset: 0;
  z-index: 89;
  border: 0;
  background: rgba(0, 12, 10, 0.62);
  backdrop-filter: blur(2px);
}

.chat-drawer {
  position: fixed;
  z-index: 90;
  display: flex;
  flex-direction: column;
  width: min(360px, calc(100vw - 24px));
  max-height: min(720px, calc(100dvh - 36px));
  overflow: hidden;
  border: 1px solid rgba(231, 196, 111, 0.48);
  border-radius: 16px;
  background:
    radial-gradient(circle at 100% 0%, rgba(143, 217, 191, 0.12), transparent 38%),
    #062c24;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.chat-header {
  padding: 16px 16px 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.chat-header h2 {
  margin: 2px 0 0;
  color: #fff5dc;
  font-size: 1.08rem;
  line-height: 1.1;
}

.chat-eyebrow {
  color: #8fd9bf;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chat-session-note {
  margin: 0;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
  color: var(--mist);
  font-size: 0.7rem;
  line-height: 1.35;
}

.chat-empty {
  min-height: 210px;
  padding: 28px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  color: var(--mist);
  text-align: center;
}

.chat-empty > span {
  color: rgba(231, 196, 111, 0.72);
  font-size: 1.8rem;
}

.chat-empty strong {
  color: #fff5dc;
  font-size: 0.88rem;
}

.chat-empty small {
  font-size: 0.72rem;
}

.chat-messages {
  min-height: 210px;
  max-height: min(430px, calc(100dvh - 280px));
  margin: 0;
  padding: 12px 14px;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scrollbar-color: rgba(143, 217, 191, 0.35) transparent;
}

.chat-messages:empty {
  display: none;
}

.chat-message {
  max-width: 88%;
  align-self: flex-start;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px 11px 11px;
  background: rgba(0, 0, 0, 0.19);
}

.chat-message.is-mine {
  align-self: flex-end;
  border-color: rgba(143, 217, 191, 0.23);
  border-radius: 11px 5px 11px 11px;
  background: rgba(20, 95, 75, 0.38);
}

.chat-message-meta {
  margin-bottom: 3px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.chat-message-meta strong {
  color: var(--brass);
  font-size: 0.69rem;
}

.chat-message-meta time {
  color: rgba(207, 238, 226, 0.52);
  font-size: 0.58rem;
}

.chat-message p {
  margin: 0;
  color: #edf8f3;
  font-size: 0.85rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-reactions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.chat-reactions.is-empty {
  justify-content: flex-end;
  min-height: 18px;
  margin-top: 1px;
}

.chat-reaction-pill,
.chat-reaction-add,
.chat-reaction-picker button {
  min-height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.055);
  color: var(--mist);
  font: inherit;
  cursor: pointer;
  transition: transform 130ms var(--ease-out), border-color 150ms ease, background 150ms ease;
}

.chat-reaction-pill {
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.72rem;
}

.chat-reaction-pill.is-mine {
  border-color: rgba(231, 196, 111, 0.68);
  background: rgba(231, 196, 111, 0.13);
  color: #fff5dc;
}

.chat-reaction-add {
  border-color: transparent;
  border-radius: 999px;
  width: 24px;
  min-height: 22px;
  padding: 0;
  background: transparent;
  color: rgba(207, 238, 226, 0.48);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
}

.chat-reactions.is-empty .chat-reaction-add {
  margin: -2px -4px -4px 0;
}

.chat-reaction-pill:active,
.chat-reaction-add:active,
.chat-reaction-picker button:active {
  transform: scale(0.94);
}

.chat-reaction-picker {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  transform-origin: left top;
}

.chat-message.is-mine .chat-reaction-picker {
  justify-content: flex-end;
  transform-origin: right top;
}

.chat-reaction-picker button {
  width: 34px;
  height: 32px;
  min-height: 32px;
  border-radius: 8px;
  padding: 0;
  font-size: 1rem;
}

@media (hover: hover) and (pointer: fine) {
  .chat-reaction-pill:hover,
  .chat-reaction-add:hover,
  .chat-reaction-picker button:hover {
    border-color: rgba(231, 196, 111, 0.58);
    background: rgba(231, 196, 111, 0.11);
  }
}

.chat-form {
  padding: 11px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.12);
}

.chat-form label {
  display: block;
  margin-bottom: 5px;
  color: var(--mist);
  font-size: 0.67rem;
  font-weight: 700;
}

.chat-form textarea {
  width: 100%;
  min-height: 56px;
  max-height: 108px;
  resize: vertical;
  border: 1px solid rgba(143, 217, 191, 0.26);
  border-radius: 9px;
  padding: 9px 10px;
  background: rgba(0, 0, 0, 0.2);
  color: #fff5dc;
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.35;
}

.chat-form textarea:focus {
  outline: 2px solid rgba(143, 217, 191, 0.42);
  outline-offset: 1px;
}

.chat-compose-footer {
  margin-top: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-compose-footer > span {
  color: var(--mist);
  font-size: 0.63rem;
  font-variant-numeric: tabular-nums;
}

.chat-compose-footer .primary-button {
  min-height: 35px;
  padding: 7px 17px;
  font-size: 0.76rem;
}

.table-effect.reaction {
  border-color: rgba(240, 199, 94, 0.78);
  background:
    linear-gradient(135deg, rgba(240, 199, 94, 0.16), transparent 54%),
    rgba(3, 28, 25, 0.96);
}

.table-effect.reaction strong {
  color: #f0c75e;
  font-size: 1.22rem;
}

.chat-message-alert {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  z-index: 1;
  width: min(430px, calc(100vw - 24px));
  min-height: 94px;
  padding: 13px 14px;
  border: 1px solid rgba(143, 217, 191, 0.82);
  border-radius: 14px;
  background:
    linear-gradient(120deg, rgba(143, 217, 191, 0.13), transparent 48%),
    rgba(3, 38, 31, 0.98);
  color: var(--paper);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.56), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  text-align: left;
  pointer-events: auto;
  animation: chatAlert 8000ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.chat-message-alert:hover,
.chat-message-alert:focus-visible {
  transform: translateX(-50%) translateY(-2px);
  border-color: var(--brass);
  box-shadow: 0 28px 78px rgba(0, 0, 0, 0.62), 0 0 0 3px rgba(231, 196, 111, 0.12);
}

.chat-alert-icon {
  width: 42px;
  height: 42px;
  margin: 0;
  border: 1px solid rgba(231, 196, 111, 0.42);
  border-radius: 12px;
  background: rgba(231, 196, 111, 0.1);
  color: var(--brass);
  display: grid;
  place-items: center;
  font-size: 1.12rem;
}

.chat-alert-body {
  min-width: 0;
  margin: 0;
  display: grid;
  gap: 2px;
}

.chat-alert-eyebrow {
  margin: 0;
  color: #8fd9bf;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chat-alert-body strong {
  color: #fff5dc;
  font-size: 0.9rem;
  line-height: 1.15;
}

.chat-alert-preview {
  margin: 0;
  color: rgba(237, 248, 243, 0.86);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-alert-action {
  margin: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding-left: 11px;
  color: var(--brass);
  font-size: 0.69rem;
  font-weight: 700;
  white-space: nowrap;
}

@keyframes chatAlert {
  0% {
    opacity: 0;
    transform: translate(-50%, -18px) scale(0.96);
  }
  7%,
  88% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.98);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-message-alert {
    animation: none;
    transform: translateX(-50%);
  }
}

@media (min-width: 1040px) {
  .app-shell {
    transition: margin-left 220ms var(--ease-out);
  }

  body.chat-is-open .app-shell {
    margin-right: auto;
    margin-left: max(10px, calc(50% - 508px));
  }

  .chat-scrim {
    display: none !important;
  }

  .chat-drawer {
    top: 18px;
    right: max(10px, calc(50% - 508px));
    left: auto;
  }
}

@media (max-width: 1039px) {
  .chat-drawer {
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 8px;
    width: auto;
    max-height: min(72dvh, 650px);
    border-radius: 16px 16px 10px 10px;
  }

  .chat-messages {
    max-height: calc(72dvh - 255px);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 10px, 430px);
    padding: 6px 0 calc(10px + env(safe-area-inset-bottom));
  }

  .table-panel {
    border-width: 5px;
    padding: 8px;
  }

  .topbar {
    flex-direction: row;
    align-items: center;
  }

  .topbar-right {
    gap: 6px;
  }

  .invite-button {
    padding: 6px 9px;
    font-size: 0.8rem;
  }

  .brand {
    font-size: 1.3rem;
  }

  .computer-upgrade {
    gap: 11px;
    padding: 11px 12px;
  }

  .computer-upgrade-copy strong {
    font-size: 0.88rem;
  }

  .field-row label:first-child {
    flex: 0 0 auto;
    width: 100%;
  }

  .opponent {
    flex-basis: calc(50% - 4px);
    border-radius: 8px;
    padding: 8px 10px;
  }

  .reaction-tray {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
    padding-right: 42px;
  }

  .reaction-tray-copy {
    width: 100%;
    flex-direction: row;
    gap: 5px;
  }

  .reaction-choice {
    width: 38px;
    height: 38px;
  }

  .chat-toggle {
    min-height: 32px;
  }

  .chat-message-alert {
    top: max(8px, env(safe-area-inset-top));
    width: calc(100vw - 16px);
    min-height: 96px;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .chat-alert-icon {
    width: 38px;
    height: 38px;
  }

  .chat-alert-action {
    grid-column: 2;
    border-left: 0;
    padding-left: 0;
  }

  .table:not([hidden]) {
    margin-top: 12px;
    gap: 10px;
  }

  .opponents {
    gap: 6px;
    margin-top: 6px;
  }

  .pile-zone {
    min-height: 118px;
    padding: 10px;
    gap: 6px;
  }

  .pile-zone::after {
    inset: 12px;
  }

  .pile-label {
    margin-top: 0;
  }

  .turn-banner {
    border-radius: 8px;
    padding: 10px 12px;
  }

  .turn-banner strong {
    font-size: 1.2rem;
  }

  .play-history summary {
    padding: 9px 10px;
  }

  .history-latest {
    max-width: 58%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .history-list {
    max-height: 270px;
  }

  .game-summary {
    padding: 10px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-stats {
    grid-template-columns: 1fr;
  }

  .hand-panel {
    padding: 10px 10px 12px;
  }

  .hand-panel.is-your-turn {
    padding-bottom: 12px;
  }

  .hand.is-fanned {
    justify-content: flex-start;
    align-items: flex-end;
    gap: 8px;
    min-height: 116px;
    margin-inline: -2px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 16px 10px 8px;
    scroll-padding-inline: 10px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
  }

  .hand.is-fanned .card {
    flex: 0 0 auto;
    margin-left: 0;
    transform: none;
  }

  .hand.is-fanned .card.selectable {
    touch-action: manipulation;
  }

  .hand.is-fanned .card.selectable:hover {
    transform: translateY(-8px) scale(1.02);
  }

  .hand.is-fanned .card.selected {
    transform: translateY(-14px);
    z-index: 3 !important;
  }

  .action-row {
    margin-top: 10px;
    gap: 8px;
  }

  .hand-panel.is-your-turn .action-row {
    position: sticky;
    z-index: 35;
    bottom: max(10px, env(safe-area-inset-bottom));
    margin: 0;
    padding: 8px;
    border: 1px solid rgba(231, 196, 111, 0.36);
    border-radius: 8px;
    background: rgba(3, 28, 25, 0.94);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }

  .utility-row {
    align-items: stretch;
    gap: 8px;
    margin-top: 0;
  }

  .utility-left {
    display: grid;
    flex: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .table-settings {
    grid-template-columns: 1fr;
  }

  .utility-left .ghost-button {
    min-width: 0;
    padding: 0 8px;
  }

  #newRoom:not([hidden]) {
    grid-column: 1 / -1;
  }

  .lobby {
    margin-top: 14px;
  }
}

/* ============================================================
   Light visual polish — preserve the existing layout, pattern,
   palette, cards, and serif identity. This only tightens the
   control system, typography rhythm, and state feedback.
   ============================================================ */

:root {
  --control-radius: 6px;
  --control-line: rgba(231, 196, 111, 0.5);
  --control-line-strong: rgba(231, 196, 111, 0.78);
  --font-display: Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-code: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

body {
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.brand,
h1,
h2,
.turn-banner strong,
.pile-play-label,
.you-label,
.summary-highlight {
  font-family: var(--font-display);
}

.card,
.mini-card,
.history-card {
  font-family: var(--font-display);
}

.room-chip strong,
.invite-code,
.room-badge strong {
  font-family: var(--font-code);
  font-variant-numeric: tabular-nums slashed-zero;
  font-feature-settings: "tnum" 1, "zero" 1;
  font-weight: 700;
  line-height: 1;
}

.seat-count,
.session-record,
.opponent-count,
.summary-grid,
.summary-stats,
.chat-message-meta time,
.chat-compose-footer > span {
  font-variant-numeric: tabular-nums;
}

.session-record,
.opponent-status {
  font-size: 0.72rem;
}

.chat-eyebrow,
.chat-form label,
.chat-compose-footer > span {
  font-size: 0.68rem;
}

.chat-message-meta strong {
  font-size: 0.72rem;
}

.chat-message-meta time {
  font-size: 0.65rem;
}

.chat-message p {
  font-size: 0.88rem;
  line-height: 1.42;
}

button,
input,
select,
textarea {
  border-radius: var(--control-radius);
}

.primary-button,
.secondary-button,
.ghost-button,
.invite-button,
.last-game-button {
  letter-spacing: 0.01em;
  transition:
    transform 140ms var(--ease-out),
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease,
    opacity 140ms ease;
}

.primary-button:not(:disabled):active,
.secondary-button:not(:disabled):active,
.ghost-button:not(:disabled):active,
.invite-button:not(:disabled):active,
.last-game-button:not(:disabled):active {
  transform: scale(0.975);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.primary-button {
  border-color: rgba(255, 226, 151, 0.8);
  background: linear-gradient(180deg, #f8dfa0 0%, #e7c46f 58%, #d2a94f 100%);
  color: #24180d;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.48),
    0 7px 16px rgba(0, 0, 0, 0.2);
  text-shadow: 0 1px rgba(255, 255, 255, 0.25);
}

.secondary-button {
  border-color: var(--control-line);
  background: linear-gradient(180deg, rgba(244, 234, 219, 0.1), rgba(244, 234, 219, 0.045));
  color: var(--paper);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.ghost-button {
  border-color: rgba(231, 196, 111, 0.38);
  background: rgba(2, 24, 20, 0.24);
  color: var(--brass);
}

input,
select,
textarea {
  border-color: rgba(244, 234, 219, 0.24);
  background: linear-gradient(180deg, rgba(2, 20, 18, 0.74), rgba(2, 20, 18, 0.6));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--control-line-strong);
  background: rgba(2, 20, 18, 0.82);
  box-shadow: 0 0 0 3px rgba(231, 196, 111, 0.09);
}

label {
  line-height: 1.2;
}

.brand,
.lobby-title,
.invite-code,
.turn-banner strong,
.game-summary h2,
.last-game-dialog-card h2 {
  text-wrap: balance;
}

.brand {
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.lobby-title {
  letter-spacing: -0.025em;
}

.lobby-sub {
  max-width: 34ch;
  margin-inline: auto;
}

.lobby-create,
.lobby-invite,
.game-summary,
.last-game-dialog,
.play-history {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 12px 30px rgba(0, 0, 0, 0.1);
}

.summary-grid div,
.summary-stat {
  border-radius: 6px;
}

.section-label,
.computer-upgrade-label,
.history-title,
.chat-eyebrow {
  letter-spacing: 0.095em;
}

.action-row .primary-button,
.action-row .secondary-button {
  min-height: 44px;
}

.chat-reaction-pill,
.chat-reaction-add,
.chat-reaction-picker button {
  box-shadow: none;
  text-shadow: none;
}

@media (hover: hover) and (pointer: fine) {
  .primary-button:not(:disabled):hover,
  .secondary-button:not(:disabled):hover,
  .ghost-button:not(:disabled):hover,
  .invite-button:not(:disabled):hover,
  .last-game-button:not(:disabled):hover {
    transform: translateY(-1px);
  }

  .primary-button:not(:disabled):hover {
    filter: brightness(1.035);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.52),
      0 10px 21px rgba(0, 0, 0, 0.25);
  }

  .secondary-button:not(:disabled):hover,
  .ghost-button:not(:disabled):hover {
    border-color: var(--control-line-strong);
    background-color: rgba(231, 196, 111, 0.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .primary-button,
  .secondary-button,
  .ghost-button,
  .invite-button,
  .last-game-button,
  input,
  select,
  textarea {
    transition-duration: 0.01ms;
  }

  .primary-button:not(:disabled):hover,
  .primary-button:not(:disabled):active,
  .secondary-button:not(:disabled):hover,
  .secondary-button:not(:disabled):active,
  .ghost-button:not(:disabled):hover,
  .ghost-button:not(:disabled):active,
  .invite-button:not(:disabled):hover,
  .invite-button:not(:disabled):active,
  .last-game-button:not(:disabled):hover,
  .last-game-button:not(:disabled):active {
    transform: none;
  }
}

[hidden] {
  display: none !important;
}
