:root {
  --felt: #1b4332;
  --felt-dark: #123024;
  --wood: #3c2415;
  --wood-dark: #2a1a0f;
  --gold: #c9a45c;
  --cream: #faf6ee;
  --ink: #1b1b1b;
  --danger: #b3223e;
  font-family: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--wood-dark);
  color: var(--cream);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.hidden { display: none !important; }

/* ---------- Lobby ---------- */
.lobby {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1e2f26 0%, #0f1a14 100%);
}
.lobby-card {
  background: linear-gradient(180deg, #1f3d2f, #16281f);
  border: 1px solid rgba(201,164,92,0.35);
  border-radius: 16px;
  padding: 36px 32px;
  width: min(360px, 88vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.lobby-card h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 44px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: 0.04em;
  color: var(--gold);
}
.lobby-sub {
  margin: 0 0 24px;
  font-size: 13px;
  color: rgba(250,246,238,0.65);
}
.field {
  display: block;
  margin-bottom: 16px;
}
.field span {
  display: block;
  font-size: 12px;
  color: rgba(250,246,238,0.6);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}
.field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid rgba(201,164,92,0.4);
  background: rgba(0,0,0,0.25);
  color: var(--cream);
  font-size: 15px;
  font-family: inherit;
}
.field input:focus {
  outline: none;
  border-color: var(--gold);
}
.btn-primary {
  width: 100%;
  padding: 13px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(180deg, var(--gold), #a3813f);
  color: #1b1408;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  letter-spacing: 0.02em;
  margin-top: 6px;
}
.btn-primary:active { transform: translateY(1px); }

.btn-secondary {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(201,164,92,0.5);
  background: rgba(201,164,92,0.08);
  color: var(--gold);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 0.02em;
  font-family: inherit;
}
.btn-secondary:active { transform: translateY(1px); }

.lobby-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 16px;
  color: rgba(250,246,238,0.35);
  font-size: 11px;
}
.lobby-divider::before, .lobby-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(201,164,92,0.25);
}
.lobby-error {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: #e88;
  text-align: center;
}

/* ---------- Table screen ---------- */
.table-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.felt-wrap {
  flex: 1;
  padding: 10px;
  min-height: 0;
}
.felt {
  position: relative;
  height: 100%;
  width: 100%;
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 50% 40%, #235943 0%, var(--felt) 55%, var(--felt-dark) 100%);
  border: 10px solid var(--wood);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.4);
  overflow: hidden;
}

.deck-pile {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 90px;
  transform: translate(-50%, -50%);
  background: url('data:image/svg+xml;utf8,') ;
  border-radius: 6px;
  cursor: pointer;
  z-index: 5;
}
.deck-pile::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(135deg, #5c1a2b, #3f0f1c);
  border: 1.5px solid var(--gold);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.3), 4px 4px 0 rgba(0,0,0,0.25);
}
.deck-count {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: rgba(250,246,238,0.7);
  white-space: nowrap;
}

.table-cards, .opponents {
  position: absolute;
  inset: 0;
}

/* Opponent seat labels arranged around the table */
.opp-seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translate(-50%, -50%);
  z-index: 3;
}
.opp-name {
  font-size: 11px;
  background: rgba(0,0,0,0.4);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--gold);
  white-space: nowrap;
  border: 1px solid rgba(201,164,92,0.3);
}
.opp-handcount {
  display: flex;
  gap: -8px;
}
.opp-card-mini {
  width: 22px;
  height: 31px;
  border-radius: 3px;
  background: linear-gradient(135deg, #5c1a2b, #3f0f1c);
  border: 1px solid var(--gold);
  margin-left: -12px;
}
.opp-card-mini:first-child { margin-left: 0; }

/* ---------- Cards ---------- */
.card {
  position: absolute;
  width: 76px;
  height: 106px;
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  transform-origin: center;
  transition: box-shadow 0.15s;
  box-shadow: 1px 2px 4px rgba(0,0,0,0.4);
}
.card.dragging {
  cursor: grabbing;
  box-shadow: 4px 8px 16px rgba(0,0,0,0.6);
  transition: none;
  z-index: 9999 !important;
}
.card svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.card.flippable {
  animation: none;
}
.card-inner {
  width: 100%;
  height: 100%;
  transition: transform 0.35s cubic-bezier(.4,.2,.2,1);
  transform-style: preserve-3d;
  position: relative;
}
.card.face-up .card-inner { transform: rotateY(180deg); }
.card-face-side, .card-back-side {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}
.card-back-side { transform: rotateY(0deg); }
.card-face-side { transform: rotateY(180deg); }

.card-stack-badge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: var(--gold);
  color: #1b1408;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 5px;
  pointer-events: none;
}

/* ---------- Hand tray ---------- */
.hand-tray {
  height: 128px;
  background: linear-gradient(180deg, var(--wood), var(--wood-dark));
  border-top: 2px solid var(--gold);
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 16px;
}
.hand-cards {
  display: flex;
  gap: 8px;
  min-width: min-content;
}
.hand-card-slot {
  position: relative;
  width: 76px;
  height: 106px;
  flex: none;
}
.hand-card-slot .card {
  position: absolute;
  top: 0; left: 0;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--wood-dark);
  border-top: 1px solid rgba(201,164,92,0.25);
  flex-wrap: wrap;
  gap: 8px;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-sm {
  background: rgba(201,164,92,0.12);
  border: 1px solid rgba(201,164,92,0.4);
  color: var(--gold);
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.btn-sm:active { transform: translateY(1px); }
.btn-sm input {
  width: 40px;
  padding: 3px 4px;
  border-radius: 4px;
  border: 1px solid rgba(201,164,92,0.4);
  background: rgba(0,0,0,0.3);
  color: var(--cream);
  font-size: 12px;
}
.btn-warn {
  border-color: rgba(179,34,62,0.6);
  color: #e88;
}
.deck-count-select {
  font-size: 12px;
  color: rgba(250,246,238,0.7);
  display: flex;
  align-items: center;
  gap: 6px;
}
.deck-count-select select {
  background: rgba(0,0,0,0.3);
  color: var(--cream);
  border: 1px solid rgba(201,164,92,0.4);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 12px;
}
.room-label {
  font-size: 11px;
  color: rgba(250,246,238,0.55);
  letter-spacing: 0.05em;
  background: none;
  border: 1px solid rgba(201,164,92,0.3);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit;
}
.room-label:active { transform: translateY(1px); }

/* ---------- Invite popover ---------- */
.invite-popover {
  position: fixed;
  z-index: 10001;
  bottom: 64px;
  right: 16px;
  background: #1f1f1f;
  border: 1px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  padding: 14px;
}
.invite-popover-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 240px;
}
.invite-label {
  font-size: 11px;
  color: rgba(250,246,238,0.6);
  letter-spacing: 0.03em;
}
.invite-popover input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid rgba(201,164,92,0.4);
  background: rgba(0,0,0,0.3);
  color: var(--cream);
  font-size: 12.5px;
  font-family: inherit;
}
.invite-popover .btn-sm {
  align-self: flex-end;
}

/* ---------- Card context menu ---------- */
.card-menu {
  position: fixed;
  z-index: 10000;
  background: #1f1f1f;
  border: 1px solid var(--gold);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  min-width: 160px;
}
.card-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  background: none;
  border: none;
  color: var(--cream);
  font-size: 13.5px;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.card-menu button:last-child { border-bottom: none; }
.card-menu button:active { background: rgba(201,164,92,0.15); }
