@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400;1,700&family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400&display=swap');

:root {
  --bg: #1a1208;
  --felt: #1c3a2a;
  --felt-light: #234832;
  --felt-dark: #152d20;
  --gold: #c9a84c;
  --gold-light: #e2c97a;
  --gold-dark: #9a7a2a;
  --cream: #f5ead8;
  --red: #c0392b;
  --red-dark: #922b21;
  --text-light: #f5ead8;
  --text-dim: #a89070;
  --card-bg: #fdf6e3;
  --card-border: #d4b896;
  --shadow: rgba(0,0,0,0.6);
  --glow: rgba(201,168,76,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 20px; }

body {
  background: var(--bg);
  font-family: 'Crimson Pro', serif;
  color: var(--text-light);
  min-height: 100vh;
  overflow: hidden;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(201,168,76,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(28,58,42,0.3) 0%, transparent 50%);
}

/* ─── SCREEN SYSTEM ─── */
.screen { display: none; }
.screen.active { display: flex; }

/* ─── TITLE SCREEN ─── */
#titleScreen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 0;
  position: relative;
}

#titleScreen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 60px, rgba(201,168,76,0.015) 60px, rgba(201,168,76,0.015) 61px),
    repeating-linear-gradient(-45deg, transparent, transparent 60px, rgba(201,168,76,0.015) 60px, rgba(201,168,76,0.015) 61px);
  pointer-events: none;
}

.title-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  pointer-events: none;
  margin-bottom: 2rem;
}

.title-ornament {
  font-size: 1.4rem;
  color: var(--gold);
  opacity: 0.5;
  letter-spacing: 0.5em;
  margin-bottom: 0.4rem;
  animation: fadeIn 1s ease;
}

.title-main {
  font-family: 'Playfair Display', serif;
  font-size: clamp(5rem, 15vw, 10rem);
  font-weight: 900;
  font-style: italic;
  color: var(--gold);
  text-shadow: 0 0 80px rgba(201,168,76,0.4), 0 4px 20px rgba(0,0,0,0.8);
  letter-spacing: -0.02em;
  line-height: 1;
  animation: titleReveal 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 0.15em;
}

.title-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  animation: fadeIn 1.5s ease;
}

.mode-select {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  animation: fadeIn 1.8s ease;
}

.mode-btn {
  background: transparent;
  border: 1px solid var(--gold-dark);
  color: var(--text-dim);
  font-family: 'Crimson Pro', serif;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active,
.mode-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.mode-btn span { position: relative; z-index: 1; }

.online-btn-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  width: 100%;
}

.online-input {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--gold-dark);
  color: var(--text-light);
  font-family: 'Crimson Pro', serif;
  font-size: 1.2rem;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 0.5rem 1rem;
  width: 100%;
  max-width: 200px;
  text-transform: uppercase;
  outline: none;
}

.online-input:focus { border-color: var(--gold); }

.online-status {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
  min-height: 1.2em;
  text-align: center;
}

.online-status.err { color: var(--red); font-style: normal; }

.room-code-block {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 6px;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
}

.room-code-display {
  font-family: 'Courier New', Courier, monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.35em;
}

.room-code-copy-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  flex-shrink: 0;
}
.room-code-copy-btn:hover { color: var(--gold); }

#mpNameInput {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--gold-dark);
  border-radius: 0;
  color: var(--text-light);
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  width: 100%;
  max-width: 260px;
  text-align: center;
  outline: none;
}

#mpNameInput:focus { border-color: var(--gold); }

/* ─── SETUP PANEL ─── */
#botPanel, #onlinePanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  width: 100%;
  max-width: 320px;
  animation: fadeIn 1.8s ease;
}

#onlinePanel { display: none; }

.setup-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
}

.setup-label {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.setup-divider {
  width: 100%;
  height: 1px;
  background: rgba(201,168,76,0.1);
}

#botPanel input,
#onlinePanel input:not(.online-input) {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  color: var(--text-light);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.45rem 0.9rem;
  text-align: center;
  outline: none;
  width: 180px;
}

#botPanel input::placeholder,
#onlinePanel input::placeholder { color: rgba(255,255,255,0.2); }

#botPanel input:focus,
#onlinePanel input:focus { border-color: rgba(201,168,76,0.5); }

.score-buttons {
  display: flex;
  gap: 0.75rem;
}

.bot-buttons {
  display: flex;
  gap: 0.75rem;
}

.online-btn-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  width: 100%;
}

#joinFlow {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.bot-btn {
  background: transparent;
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 0.65rem 2rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.bot-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.2s;
}

.bot-btn:hover { border-color: var(--gold); color: var(--bg); }
.bot-btn:hover::after { opacity: 1; }
.bot-btn span { position: relative; z-index: 1; }

/* Active state set via JS inline style; also handle initial active */
.bot-btn.active {
  background: var(--gold);
  color: var(--bg);
}

.score-btn {
  background: transparent;
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.75rem 2.5rem;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.score-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.2s;
}

.score-btn:hover { border-color: var(--gold); color: var(--bg); }
.score-btn:hover::after { opacity: 1; }
.score-btn.active { background: var(--gold); color: var(--bg); }
.score-btn span { position: relative; z-index: 1; }

.start-btn {
  background: var(--gold);
  border: 1px solid transparent;
  color: var(--bg);
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.8rem 2.5rem;
  cursor: pointer;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: all 0.2s;
  box-shadow: 0 4px 30px rgba(201,168,76,0.3);
}

.start-btn:hover {
  background: var(--gold-light);
  box-shadow: 0 6px 40px rgba(201,168,76,0.5);
  transform: translateY(-1px);
}

/* Deal button hidden until score selected */
#startBtn { display: none; }

.start-btn-outline {
  background: transparent;
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: none;
}
.start-btn-outline:hover {
  background: rgba(201,168,76,0.1);
  box-shadow: none;
}

/* ─── GAME SCREEN ─── */
#gameScreen {
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  padding: 0.75rem;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

/* ─── MAIN LAYOUT: board left, log right ─── */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Left column: table area + action panel */
.board-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  overflow: visible;
}

/* Right column: log taking full height */
.log-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  gap: 0.75rem;
}

.log-section,
.chat-section {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.side-label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.5);
  flex-shrink: 0;
}

/* ─── LOG ─── */
.log-area {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: 4px;
  padding: 0.6rem 0.8rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.log-entry {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.7;
  font-style: italic;
}

/* ─── CHAT ─── */
.chat-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: 4px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.8rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.chat-messages:empty::after {
  content: 'No messages yet…';
  color: var(--text-dim);
  font-size: 0.8rem;
  font-style: italic;
  opacity: 0.45;
  margin: auto;
  align-self: center;
}

.chat-msg {
  font-size: 0.82rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.chat-msg:first-child {
  padding-top: 0;
  border-top: none;
}

.chat-msg-name {
  font-weight: 600;
  color: var(--gold);
}

.chat-msg-name.is-me {
  color: var(--text-light);
}

.chat-msg-text {
  color: var(--text-dim);
  padding-left: 0.6rem;
  word-break: break-word;
}

.chat-input-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  border-top: 1px solid rgba(201,168,76,0.08);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  outline: none;
}

.chat-send-btn {
  background: rgba(201,168,76,0.12);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  color: var(--gold);
  font-size: 1rem;
  padding: 0.3rem 0.6rem;
  cursor: not-allowed;
  opacity: 0.4;
}

/* ─── SCORE BAR ─── */
.score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 1.2rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  flex-shrink: 0;
}

.score-player {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.score-name {
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.score-value {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gold);
  min-width: 3ch;
  text-align: center;
}

.score-target {
  font-size: 0.9rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.score-divider {
  width: 1px;
  height: 2rem;
  background: rgba(201,168,76,0.2);
}

/* ─── BOARD ─── */
.board {
  display: contents;
}

.zone {
  background: var(--felt);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  position: relative;
}

.zone-label {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-bottom: 0;
  font-family: 'Crimson Pro', serif;
  font-weight: 600;
  opacity: 0.9;
  flex: 1;
}

.zone-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.zone-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  flex-shrink: 0;
  visibility: hidden;
}

.zone-pip.active {
  visibility: visible;
  animation: pulse 1.5s infinite;
}

.zone-score {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--gold);
  min-width: 2ch;
  text-align: right;
  line-height: 1;
}

.pile-btn {
  background: transparent;
  border: none;
  color: var(--gold-light);
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline dotted rgba(201,168,76,0.5);
  text-underline-offset: 3px;
  padding: 0;
  transition: color 0.15s;
}
.pile-btn:hover { color: var(--gold); text-decoration-color: var(--gold); }

.pile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 90px);
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.25rem;
}

.pile-card {
  width: 90px;
  height: 126px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.5);
}

.pile-card img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  image-rendering: crisp-edges;
  display: block;
}

.escoba-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(201,168,76,0.2);
  border: 1px solid var(--gold-dark);
  border-radius: 20px;
  padding: 0.1rem 0.6rem;
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  margin-left: 0.75rem;
  vertical-align: middle;
}

.escoba-badge-icon {
  font-size: 0.9rem;
}

/* Bot zone — compact info strip, no card fan */
.bot-zone {
  background: linear-gradient(135deg, var(--felt-dark), var(--felt));
  flex-shrink: 0;
  padding: 0.4rem 1rem;
}

.bot-zone .zone-label {
  margin-bottom: 0;
}

/* Center zone */
.center-zone {
  background: var(--felt);
  border-color: rgba(201,168,76,0.25);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.card-canvas {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.center-zone .cards-row {
  display: none; /* replaced by free canvas */
}

.card-canvas .card {
  position: absolute;
  cursor: grab;
  touch-action: none;
}

.card-canvas .card:active { cursor: grabbing; }

.card-canvas .card.drag-over-invalid {
  filter: drop-shadow(0 0 8px rgba(192,57,43,0.8));
}

/* Drop slot ghost */
.card-canvas.drag-target {
  border: 2px dashed rgba(201,168,76,0.5);
  background: rgba(201,168,76,0.04);
  border-radius: 6px;
}

.drop-slot {
  position: absolute;
  width: 80px;
  height: 112px;
  border: 2px dashed rgba(201,168,76,0.3);
  border-radius: 8px;
  pointer-events: none;
  transition: opacity 0.15s;
  opacity: 0;
}

.drop-slot.visible { opacity: 1; }

/* Player zone */
.player-zone {
  background: linear-gradient(135deg, var(--felt), var(--felt-light));
}

/* ─── CARDS ─── */
.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, 80px);
  gap: 0.8rem;
  min-height: 100px;
  align-items: start;
  justify-content: center;
}

/* Player hand fan */
.hand-fan {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 80px;
  padding-bottom: 0.5rem;
  position: relative;
  flex-shrink: 0;
}

.hand-fan .card {
  position: relative;
  margin: 0 -18px;
  transform-origin: center bottom;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.15s;
}

.hand-fan .card.selectable:hover {
  transform: var(--fan-transform) translateY(-28px) scale(1.08) !important;
  z-index: 20 !important;
}

.hand-fan .card.selected {
  transform: var(--fan-transform) translateY(-36px) scale(1.08) !important;
  z-index: 20 !important;
}

/* Bot hand fan — hidden; bot zone is a compact info strip */
.hand-fan-bot {
  display: none;
}

.hand-fan-bot .card {
  position: relative;
  margin: 0 -30px;
  transform-origin: center top;
  transition: transform 0.18s ease, filter 0.15s;
}

.card {
  width: 80px;
  height: 112px;
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: none;
  transition: transform 0.15s, filter 0.15s;
  cursor: default;
  user-select: none;
  overflow: visible;
  padding: 0;
  outline: none;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
  filter: drop-shadow(3px 4px 6px rgba(0,0,0,0.7));
  transition: filter 0.15s, transform 0.15s;
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

.card.face-down {
  background: transparent;
  border: none;
}

.card-number, .card-suit, .card-name { display: none; }

/* Suit colors - kept for any fallback text */
.suit-oros .card-number, .suit-oros .card-suit { color: #b8860b; }
.suit-copas .card-number, .suit-copas .card-suit { color: #c0392b; }
.suit-espadas .card-number, .suit-espadas .card-suit { color: #2c3e50; }
.suit-bastos .card-number, .suit-bastos .card-suit { color: #27ae60; }

/* Special cards — subtle glow only, no border */
.card.golden-7 img { filter: drop-shadow(3px 4px 6px rgba(0,0,0,0.7)) drop-shadow(0 0 8px rgba(201,168,76,0.6)); }
.card.golden-king img { filter: drop-shadow(3px 4px 6px rgba(0,0,0,0.7)) drop-shadow(0 0 6px rgba(201,168,76,0.4)); }

/* Selectable */
.card.selectable { cursor: pointer; }

.card.selectable:hover {
  transform: translateY(-10px) scale(1.06);
  z-index: 10;
}

.card.selectable:hover img {
  filter: drop-shadow(4px 12px 16px rgba(0,0,0,0.8));
}

.card.selected {
  transform: translateY(-14px) scale(1.06);
  z-index: 10;
}

.card.selected img {
  filter: drop-shadow(4px 14px 18px rgba(0,0,0,0.8)) drop-shadow(0 0 8px rgba(201,168,76,0.8));
}

.card.center-selected {
  transform: translateY(-10px) scale(1.08);
  z-index: 10;
}

.card.opponent-selected {
  transform: translateY(-6px) scale(1.04);
  z-index: 9;
}

.card.opponent-selected img {
  filter: drop-shadow(4px 8px 12px rgba(0,0,0,0.7)) drop-shadow(0 0 8px rgba(120,180,255,0.5));
}

.card.opponent-selected::before {
  content: '✓';
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  background: #6ab0f5;
  color: var(--bg);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 24px;
  text-align: center;
  font-family: sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  z-index: 20;
  opacity: 0.8;
}

.card.center-selected img {
  filter: drop-shadow(4px 12px 16px rgba(0,0,0,0.8)) drop-shadow(0 0 10px rgba(201,168,76,0.9));
}

.card.center-selected::before {
  content: '✓';
  position: absolute;
  top: -10px;
  right: -10px;
  width: 24px;
  height: 24px;
  background: var(--gold);
  color: var(--bg);
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 24px;
  text-align: center;
  font-family: sans-serif;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  z-index: 20;
}

.card.escoba-marker {
  transform: rotate(90deg);
  margin: 0 16px;
}

/* Pile display */
.pile-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.pile-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-style: italic;
}

/* ─── ACTION PANEL ─── */
.action-panel {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
  height: 52px;
  overflow: hidden;
}

.action-hint {
  font-size: 1rem;
  color: var(--text-dim);
  font-style: italic;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn {
  background: transparent;
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  padding: 0.55rem 1.4rem;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.05em;
  border-radius: 2px;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--gold);
  color: var(--bg);
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--gold);
  color: var(--bg);
  font-weight: 600;
  border-color: var(--gold);
}

.btn.primary:hover {
  background: var(--gold-light);
}

.btn.btn-escoba {
  border-color: var(--gold);
  color: var(--gold);
  padding: 0.2rem 0.75rem;
  font-size: 0.85rem;
  align-self: center;
}

.btn.btn-escoba:hover:not(:disabled) {
  background: var(--gold);
  color: var(--bg);
}

.btn.danger {
  border-color: var(--red-dark);
  color: var(--red);
}

.btn.danger:hover:not(:disabled) {
  background: var(--red);
  color: white;
}

.log-entry.highlight { color: var(--gold); }
.log-entry.points { color: #7ec8a0; }
.log-entry.escoba { color: var(--gold); font-weight: 600; }
.log-entry.bot { color: #a0b8d0; }

/* ─── ROUND SUMMARY MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: #1a1a0e;
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 40px rgba(201,168,76,0.1);
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-style: italic;
  color: var(--gold);
  margin-bottom: 1.5rem;
  text-align: center;
}

.modal-section {
  margin-bottom: 1.25rem;
}

.modal-section h3 {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(201,168,76,0.15);
  padding-bottom: 0.3rem;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.95rem;
}

.score-row .pts {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  color: var(--gold);
}

.score-row .pts.zero { color: var(--text-dim); }

.score-row.total {
  border-top: 1px solid rgba(201,168,76,0.2);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  font-weight: 600;
  font-size: 1.05rem;
}

.modal-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

/* ─── JOKER VALUE MODAL ─── */
.joker-modal {
  max-width: 360px;
}

.joker-modal p {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 1.2rem;
  text-align: center;
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.val-btn {
  background: transparent;
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.6rem;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.val-btn:hover { background: var(--gold); color: var(--bg); }

.skip-btn-row {
  display: flex;
  justify-content: center;
}

/* ─── TURN INDICATOR ─── */
.turn-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.turn-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold);
  animation: pulse 1.5s infinite;
}

.turn-label {
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ─── ANIMATIONS ─── */
/* Unset joker on table — pulsing gold ring to indicate it needs a value */
.card.unset-joker::after {
  content: '✦ tap to set value';
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  color: var(--gold);
  white-space: nowrap;
  animation: pulse 1.5s infinite;
  pointer-events: none;
  font-family: 'Crimson Pro', serif;
}

.card.unset-joker img {
  animation: jokerPulseRing 1.8s ease-in-out infinite;
}

@keyframes jokerPulseRing {
  0%, 100% { filter: drop-shadow(3px 4px 6px rgba(0,0,0,0.7)) drop-shadow(0 0 4px rgba(201,168,76,0.3)); }
  50%       { filter: drop-shadow(3px 4px 6px rgba(0,0,0,0.7)) drop-shadow(0 0 14px rgba(201,168,76,0.9)); }
}
@keyframes dealFromDeck {
  from {
    opacity: 0.9;
    transform: translate(var(--deal-from-x), var(--deal-from-y)) rotate(var(--deal-rot, 0deg)) scale(0.7);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}
.card.animating-deal-player { animation: dealFromDeck 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
.card.animating-deal-bot    { animation: dealFromDeck 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
.card.animating-deal-center { animation: dealFromDeck 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
.card.animating-capture { opacity: 0 !important; transition: opacity 0.15s; }
@keyframes captureFlash {
  to { opacity: 0; }
}

.capture-fly-clone {
  position: absolute;
  pointer-events: none;
  z-index: 49;
  transition: transform 0.5s ease-in, opacity 0.25s 0.9s;
}
@keyframes titleReveal {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ─── ZONE DECLARATION POPUP ─── */
.zone-declaration {
  position: fixed;
  z-index: 8000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: rgba(10, 8, 4, 0.88);
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: 6px;
  padding: 0.45rem 0.9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.7);
  animation: zoneDeclFade 1.8s ease forwards;
}

.zone-decl-total {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #7ec8a0;
}

.zone-decl-reasons {
  font-family: 'Crimson Pro', serif;
  font-size: 0.85rem;
  color: var(--cream);
  letter-spacing: 0.05em;
  text-align: center;
}

@keyframes zoneDeclFade {
  0%   { opacity: 0; transform: translateY(0px); }
  15%  { opacity: 1; transform: translateY(-10px); }
  70%  { opacity: 1; transform: translateY(-22px); }
  100% { opacity: 0; transform: translateY(-36px); }
}

/* ─── TOASTS & DECLARATION ANIMATIONS ─── */
.toast-container {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: rgba(20,14,4,0.95);
  border: 1px solid var(--gold-dark);
  border-radius: 6px;
  padding: 0.6rem 1.4rem;
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  color: var(--text-light);
  box-shadow: 0 4px 24px rgba(0,0,0,0.7);
  animation: toastIn 0.3s cubic-bezier(0.16,1,0.3,1), toastOut 0.4s ease 2.6s forwards;
  white-space: nowrap;
}

.toast.warn {
  border-color: var(--red-dark);
  color: var(--red);
}

.toast.points {
  border-color: rgba(126,200,160,0.6);
  color: #7ec8a0;
  font-size: 1.05rem;
}

/* Chorizo splash — full screen flash */
.chorizo-splash {
  position: fixed;
  inset: 0;
  z-index: 8999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  animation: chorizoFade 2.2s ease forwards;
}

.chorizo-splash-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(201,168,76,0.18) 0%, transparent 70%);
  animation: chorizo-pulse 2.2s ease forwards;
}

.chorizo-text {
  position: relative;
  font-family: 'Playfair Display', serif;
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 900;
  font-style: italic;
  color: var(--gold);
  text-shadow:
    0 0 40px rgba(201,168,76,0.9),
    0 0 80px rgba(201,168,76,0.5),
    0 4px 20px rgba(0,0,0,0.9);
  animation: chorizoText 2.2s cubic-bezier(0.16,1,0.3,1) forwards;
  letter-spacing: -0.02em;
}

.chorizo-pts {
  position: relative;
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold-light);
  margin-top: 0.5rem;
  text-align: center;
  text-shadow: 0 0 20px rgba(201,168,76,0.6);
  animation: chorizoText 2.2s cubic-bezier(0.16,1,0.3,1) 0.1s forwards;
}

.chorizo-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}
@keyframes chorizoFade {
  0%   { opacity: 0; }
  10%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes chorizo-pulse {
  0%   { transform: scale(0.8); opacity: 0; }
  15%  { transform: scale(1.1); opacity: 1; }
  60%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.2); opacity: 0; }
}
@keyframes chorizoText {
  0%   { opacity: 0; transform: scale(0.5) rotate(-4deg); }
  15%  { opacity: 1; transform: scale(1.05) rotate(1deg); }
  25%  { transform: scale(1) rotate(0deg); }
  75%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.9) translateY(-10px); }
}
@media (max-width: 480px) {
  .card { width: 56px; height: 78px; }
  .card-number { font-size: 1.7rem; }
  .card-suit { font-size: 1.1rem; }
  .cards-row { grid-template-columns: repeat(auto-fill, 56px); }
}

/* ─── GAME OVER ─── */
.winner-badge {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-style: italic;
  color: var(--gold);
  text-align: center;
  text-shadow: 0 0 40px rgba(201,168,76,0.5);
  margin-bottom: 0.5rem;
}

.winner-sub {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.final-scores {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-bottom: 1.5rem;
}

.final-score-item {
  text-align: center;
}

.final-score-item .name {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.final-score-item .val {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gold);
}

/* Phase label in action panel */
.phase-label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.6);
  padding: 0.2rem 0.6rem;
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 2px;
}

.hand-points-display {
  font-size: 0.8rem;
  color: #7ec8a0;
  font-style: italic;
}

/* Joker value overlay — covers the original rank number */
.joker-num-cover {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: linear-gradient(to bottom, #12221a 90%, rgba(18,34,26,0) 100%);
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5px;
  pointer-events: none;
  z-index: 1;
}
.joker-num-text {
  font-family: Georgia, serif;
  font-weight: bold;
  letter-spacing: 0.02em;
  line-height: 1;
}
.suit-oros    .joker-num-text { color: #c9a84c; }
.suit-copas   .joker-num-text { color: #c94c4c; }
.suit-espadas .joker-num-text { color: #8aaabf; }
.suit-bastos  .joker-num-text { color: #7a9e5a; }

/* Redraw card border on top of the joker overlay */
.card:has(.joker-num-cover)::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1.5px rgba(201,168,76,0.8), inset 0 0 0 2.5px rgba(201,168,76,0.15);
  pointer-events: none;
  z-index: 2;
}

/* ─── TABLE AREA (wraps center zone + widget overlays) ─── */
.table-area {
  position: relative;
  flex: 1;
  min-height: 0;
  /* Felt texture: base colour + subtle diagonal weave */
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      rgba(0,0,0,0.04) 3px,
      rgba(0,0,0,0.04) 6px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 3px,
      rgba(0,0,0,0.03) 3px,
      rgba(0,0,0,0.03) 6px
    ),
    radial-gradient(ellipse at 50% 45%, #1e4028 0%, #0d1f10 75%);
  border-radius: 12px;
}

.table-area .center-zone {
  position: absolute;
  inset: 0;
}

/* ─── TABLE WATERMARK ─── */
.table-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  opacity: 0.1;
}

.table-logo {
  font-family: 'Playfair Display', serif;
  font-size: 4.5rem;
  font-weight: 900;
  font-style: italic;
  color: var(--gold);
  line-height: 1;
  letter-spacing: -0.02em;
}

.table-ornament {
  font-size: 1rem;
  color: var(--gold);
  letter-spacing: 0.5em;
  margin: 0.3rem 0;
}

.table-target {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 0.2rem;
}

/* ─── CAPTURE FLIP CARD (multiplayer) ─── */
.capture-flip-card {
  width: 80px;
  height: 112px;
  perspective: 500px;
}

.capture-flip-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.capture-flip-card.flipped .capture-flip-inner {
  transform: rotateY(180deg);
}

.capture-flip-front,
.capture-flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}

.capture-flip-front {
  transform: rotateY(180deg);
}

/* ─── JOKER CHANGEABLE BADGE ─── */
.joker-changeable-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px rgba(201,168,76,0.8);
  pointer-events: none;
  animation: jokerBadgePulse 2s ease-in-out infinite;
}

@keyframes jokerBadgePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.55; transform: scale(0.75); }
}

.table-sum {
  position: absolute;
  bottom: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  user-select: none;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.table-sum-num {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.table-sum-label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ─── PLAYER / BOT WIDGETS ─── */
.widget-wrap {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.player-widget { bottom: 1rem; left: 1rem; }
.bot-widget    { top: 1rem;    right: 1rem; }

.pip-ring {
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 0 0 rgba(201,168,76,0);
}

.widget-wrap.active .pip-ring {
  animation: pipPulse 1.5s ease-in-out infinite;
}

@keyframes pipPulse {
  0%,100% { opacity: 0.2; transform: scale(0.96); box-shadow: 0 0 4px  rgba(201,168,76,0.2); }
  50%     { opacity: 1;   transform: scale(1);    box-shadow: 0 0 14px rgba(201,168,76,0.6); }
}

.player-circle {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--felt-dark) 0%, var(--felt) 100%);
  border: 2px solid var(--gold-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  overflow: hidden;
  position: relative;
}

.widget-name {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 140px;
  background: var(--felt-dark);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  padding: 4px 10px;
  text-align: center;
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--gold-light);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 10;
  pointer-events: none;
}

.w-card-slot {
  width: 52px;
  height: 52px;
  border-radius: 5px;
  position: relative;
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.w-empty {
  border: 1px dashed rgba(201,168,76,0.3);
  background: rgba(0,0,0,0.25);
}

.w-has-cards {
  overflow: hidden;
  box-shadow: 2px 4px 10px rgba(0,0,0,0.6);
  cursor: pointer;
}

.widget-pile-count {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -58%);
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 2rem;
  line-height: 1;
  color: var(--gold-light);
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
  pointer-events: none;
  padding-bottom: 0;
}

.widget-stats-row {
  display: flex;
  justify-content: center;
  gap: 1.1rem;
  margin-top: 0.25rem;
}

.widget-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.widget-stat .pts-num {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--gold);
  line-height: 1;
}

.widget-stat .pts-label {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 0.1rem;
}


.widget-dealer-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  left: auto;
  top: auto;
  transform: none;
  z-index: 11;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 0.7rem;
  color: var(--bg);
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

/* ─── DECLARATION SPEECH BUBBLE ─── */
@keyframes bubbleFade {
  0%   { opacity: 0; transform: translateY(6px) scale(0.95); }
  12%  { opacity: 1; transform: translateY(0)   scale(1);    }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

.widget-bubble {
  position: fixed;
  z-index: 9999;
  max-width: 200px;
  padding: 0.55rem 0.85rem;
  background: rgba(12, 20, 14, 0.94);
  border: 1px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.6), 0 0 8px rgba(200,160,60,0.18);
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--gold-light, #f0d080);
  line-height: 1.4;
  text-align: center;
  pointer-events: none;
  animation: bubbleFade 2.4s ease forwards;
}

/* Tail pointing down-left — for player bubble (appears above player widget) */
.bubble-player::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 22px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid var(--gold);
}
.bubble-player::before {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 23px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid rgba(12,20,14,0.94);
  z-index: 1;
}

/* Tail pointing up-right — for bot bubble (appears below bot widget) */
.bubble-bot::after {
  content: '';
  position: absolute;
  top: -8px;
  right: 22px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 8px solid var(--gold);
}
.bubble-bot::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 23px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 7px solid rgba(12,20,14,0.94);
  z-index: 1;
}

/* ─── HAND FAN OVERLAY (floats over table at bottom-centre) ─── */
.hand-fan-overlay {
  position: absolute;
  bottom: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 280px;
  height: 160px;
  padding: 0 2rem;
  z-index: 10;
  pointer-events: none;
}

.hand-fan-overlay::before {
  content: 'Your Hand';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.5);
  pointer-events: none;
  white-space: nowrap;
}

.hand-fan-overlay .card {
  pointer-events: auto;
  position: relative;
  margin: 0 -8px;
  transform-origin: center bottom;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.15s;
}

.hand-fan-overlay .card.selectable:hover {
  transform: var(--fan-transform) translateY(-28px) scale(1.08) !important;
  z-index: 20 !important;
}

.hand-fan-overlay .card.selected {
  transform: var(--fan-transform) translateY(-36px) scale(1.08) !important;
  z-index: 20 !important;
}

/* ─── BOT WIDGETS CONTAINER ─── */
/* Absolute overlay covering the whole table-area; children are the bot widgets */
.bots-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.bots-container .bot-widget {
  pointer-events: auto;
  position: absolute;
}

/* 1 bot: top-right (mirrors original layout) */
.bots-1 .bot-widget:nth-child(1) {
  top: 1rem;
  right: 1rem;
  left: auto;
}

/* 2 bots: top-left and top-right */
.bots-2 .bot-widget:nth-child(1) {
  top: 1rem;
  left: 1rem;
  right: auto;
}
.bots-2 .bot-widget:nth-child(2) {
  top: 1rem;
  right: 1rem;
  left: auto;
}

/* 3 bots: evenly spaced across the top */
.bots-3 .bot-widget {
  top: 1rem;
  right: auto;
}
.bots-3 .bot-widget:nth-child(1) { left: calc(16% - 85px); }
.bots-3 .bot-widget:nth-child(2) { left: 50%; transform: translateX(-50%); }
.bots-3 .bot-widget:nth-child(3) { left: calc(84% - 85px); }



/* ─── BOT PIP ─── */
.bot-pip {
  font-size: 0.42rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.55;
  margin-top: 0.1rem;
}

/* ─── LOG SECTION HEADER ROW ─── */
.side-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem 0.3rem;
}
.side-label-row .side-label {
  padding: 0;
}
.dev-btn {
  background: none;
  border: 1px solid var(--gold-dark);
  color: var(--gold-dark);
  font-family: 'Crimson Pro', serif;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.dev-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ─── DEV PANEL ─── */
.dev-panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 2000;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}
.dev-panel {
  width: min(520px, 95vw);
  background: #111a14;
  border-left: 1px solid var(--gold-dark);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dev-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(201,168,76,0.15);
  flex-shrink: 0;
  min-height: 2.6rem;
}
.dev-tabs {
  display: flex;
  gap: 0;
}
.dev-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: 'Crimson Pro', serif;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.7rem 0.75rem 0.6rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.dev-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.dev-tab:hover:not(.active) { color: var(--text-light); }
.dev-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.2rem;
}
.dev-close-btn:hover { color: var(--text-light); }
.dev-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.dev-empty {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.8rem;
  text-align: center;
  padding: 2rem;
}
.dev-entry {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.dev-entry-latest {
  border-color: rgba(201,168,76,0.3);
  background: rgba(201,168,76,0.04);
}
.dev-entry-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}
.dev-bot-name {
  font-family: 'Playfair Display', serif;
  font-size: 0.8rem;
  color: var(--gold-light);
  font-style: italic;
}
.dev-tag {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
}
.dev-tag-capture { background: rgba(192,57,43,0.25); color: #e0786a; }
.dev-tag-place   { background: rgba(28,58,42,0.5);   color: #7ec896; }
.dev-chosen-score {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 0.65rem;
}
.dev-section-label {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 0.25rem;
}
.dev-hand, .dev-table {
  color: var(--text-light);
  line-height: 1.5;
  font-size: 0.72rem;
}
.dev-chosen {
  color: var(--gold-light);
  font-style: italic;
  line-height: 1.4;
}
.dev-alts-title {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
.dev-alt-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.68rem;
}
.dev-alt-label { color: var(--text-dim); flex: 1; }
.dev-alt-score {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ─── DEV TOOLS ─── */
.dev-tool-section {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.dev-tool-title {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-dark);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.dev-tool-hint {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 0;
  text-transform: none;
}
.dev-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.dev-score-row:last-of-type { border-bottom: none; }
.dev-player-label {
  font-family: 'Playfair Display', serif;
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-light);
  min-width: 5rem;
}
.dev-score-controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.dev-adj-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-light);
  font-size: 0.7rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.dev-adj-btn:hover { background: rgba(201,168,76,0.15); }
.dev-score-cur {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--gold-light);
  min-width: 2rem;
  text-align: center;
}
.dev-hand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 4px;
  margin-top: 0.25rem;
}
.dev-card-thumb {
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s, opacity 0.15s;
}
.dev-card-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.dev-card-thumb.unavail { opacity: 0.22; cursor: default; }
.dev-card-thumb.avail:hover { border-color: var(--gold-dark); }
.dev-card-thumb.sel { border-color: var(--gold); box-shadow: 0 0 6px var(--glow); }
.dev-hand-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.35rem;
}
.dev-sel-count {
  font-size: 0.68rem;
  color: var(--text-dim);
}
.dev-tool-btn {
  background: rgba(201,168,76,0.12);
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: 'Crimson Pro', serif;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.dev-tool-btn:hover { background: rgba(201,168,76,0.22); }
.dev-tool-btn-danger {
  background: rgba(192,57,43,0.15);
  border-color: #922b21;
  color: #e07060;
}
.dev-tool-btn-danger:hover { background: rgba(192,57,43,0.28); }

/* ─── LOBBY SCREEN ─── */
#lobbyScreen {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

.lobby-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.lobby-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: 2.5rem 2rem;
  min-width: 0;
  overflow-y: auto;
}

.lobby-right {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 2rem 1rem;
  border-left: 1px solid rgba(201,168,76,0.08);
}

.lobby-chat-area {
  flex: 1;
  min-height: 0;
}

.lobby-code-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}

.lobby-code-label {
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.lobby-code-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-style: italic;
}

.lobby-players {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 320px;
}

.lobby-player {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.85rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(201,168,76,0.15);
  border-radius: 6px;
}

.lobby-player-name {
  font-size: 0.9rem;
  color: var(--text-light);
}

.lobby-player-badge {
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.7;
}

.lobby-player-empty {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.85rem;
  justify-content: center;
}

#lobbyScoreWrap {
  width: 100%;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin-top: auto;
  padding-top: 0.5rem;
}

.lobby-waiting {
  font-size: 0.82rem;
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 0.06em;
}

.lobby-back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.15s;
}
.lobby-back-btn:hover { color: var(--text-light); }

/* Score buttons read-only for guest */
#lobbyScoreWrap .score-btn:disabled {
  cursor: default;
  color: var(--text-dim);
  border-color: rgba(201,168,76,0.2);
}
#lobbyScoreWrap .score-btn:disabled:hover {
  transform: none;
  background: transparent;
  box-shadow: none;
}
#lobbyScoreWrap .score-btn:disabled.active {
  background: rgba(201,168,76,0.15);
  color: var(--text-dim);
  border-color: rgba(201,168,76,0.3);
}

/* ─── CHAT CLEAR BUTTON ─── */
.chat-clear-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.chat-clear-btn:hover { color: var(--text-light); }

.title-credit {
  position: absolute;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: 'Crimson Pro', serif;
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.6;
}

.title-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s;
}

.title-credit a:hover { opacity: 1; }

.title-kofi {
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none !important;
  border: 1px solid var(--text-dim);
  padding: 3px 8px;
  border-radius: 4px;
  transition: opacity 0.15s;
}

.title-kofi svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
  flex-shrink: 0;
}

