: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;
  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:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.28);
}

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(100vw - 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;
}

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

.field-row label:last-child {
  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);
}

.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;
}

.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.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 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 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 label:last-child {
    width: 100%;
  }

  .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;
  }

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

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

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

/* ============================================================
   Redesign: slim header, lobby/invite landing, table reflow
   (opponents → pile → turn banner → hand). Appended last so
   these rules win over the earlier layout by source order.
   ============================================================ */

: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;
}

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

.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-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);
}

.room-actions {
  display: flex;
  flex-direction: column;
  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;
}

/* 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);
}

@media (max-width: 760px) {
  .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;
  }

  .opponent {
    flex-basis: calc(50% - 4px);
  }

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

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

[hidden] {
  display: none !important;
}
