:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --ink: #e8e8ea;
  --dim: #8a8f98;
  --accent: #ffcf4d;
  --oros: #f1c40f;
  --copas: #e74c3c;
  --espadas: #4dd0e1;
  --bastos: #2ecc71;
  --card: #23262f;
  --border: #333845;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}
html:has(#game:not(.hidden)),
html:has(#game:not(.hidden)) body {
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overscroll-behavior: none;
  touch-action: manipulation;
}
.hidden { display: none !important; }
.dim { color: var(--dim); font-weight: normal; font-size: 0.85em; }

#app { max-width: 760px; margin: 0 auto; padding: 16px; }

.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; margin-top: 24px;
}

h1 { margin: 0; letter-spacing: 2px; color: var(--accent); }
/* Landing title: 2x the default h1 (32px -> 64px); shrinks with the viewport on narrow phones so it never overflows. */
#title { font-size: min(64px, 14vw); }
/* Landing tagline under the CHINCHON title: same yellow, smaller. Spanish in both languages (not translated). */
.tagline { margin: 4px 0 12px; color: var(--accent); font-size: 0.85em; font-weight: 600; }

label { display: block; margin: 12px 0 6px; color: var(--dim); font-size: 0.85em; }
input {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border);
  background: #11141a; color: var(--ink); font-size: 1em; margin-top: 4px;
}
/* Landing name field: no need for the full card width. Keeps 1em text (no
   iOS zoom-on-focus) and ~36px height so it stays easy to tap. */
#lobby-name { max-width: 260px; padding: 8px 10px; }
button {
  cursor: pointer; border: none; border-radius: 8px; padding: 10px 16px;
  background: #2a2f3a; color: var(--ink); font-size: 1em; margin: 12px 8px 0 0;
}
button.primary { background: var(--accent); color: #1a1d24; font-weight: 700; }
button.small { padding: 4px 10px; font-size: 0.8em; }
button.danger { background: #c0392b; color: #fff; font-weight: 700; }
#lobby-main .danger { margin: 0 8px 0 0; width: auto; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab { background: #2a2f3a; }
.tab.active { background: var(--accent); color: #1a1d24; font-weight: 700; }
.code { font-size: 1.6em; font-weight: 700; letter-spacing: 4px; color: var(--accent); }
.msg { color: var(--accent); min-height: 1.2em; }
ul#lobby-players { padding-left: 18px; color: var(--ink); }

/* Board */
#board-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.board-top-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#btn-leave-match { margin-left: auto; }
#scoreboard { font-size: 0.9em; }
#scoreboard .row { margin: 2px 0; }
#scoreboard .out { color: var(--dim); text-decoration: line-through; }
#scoreboard .kick { margin: 0 0 0 4px; padding: 0 6px; font-size: 0.8em; line-height: 1.5; vertical-align: middle; }
#turn-banner { color: var(--accent); font-weight: 700; }

/* ---- The table: an oval felt with a wooden rim ---- */
#table {
  position: relative; width: 100%; max-width: 780px; height: 430px; margin: 12px auto 22px;
  border-radius: 50% / 50%;
  /* Blue felt (Nov 3, 2026, Dannel: "make the table cloth blue instead"). */
  background: radial-gradient(ellipse at 50% 42%, #2f6aa8 0%, #23558c 55%, #183d66 100%);
  box-shadow:
    inset 0 0 0 9px #6e4524, inset 0 0 0 12px #3f2713,
    inset 0 0 46px rgba(0,0,0,.5), 0 12px 28px rgba(0,0,0,.45);
}
#opponents { position: absolute; inset: 0; pointer-events: none; }
.seat {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 9px 4px; border-radius: 16px; min-width: 74px; max-width: 120px;
  background: rgba(8, 16, 32, 0.42); color: #f3efe2; text-align: center;
}
.seat-fan { position: relative; width: 70px; height: 34px; }
.mini-back {
  position: absolute; bottom: 0; width: 20px; height: 30px; border-radius: 3px;
  background: #f7f3e9 url("card-back.jpg") center/cover no-repeat;
  border: 1px solid #d8cfb8; box-shadow: 0 1px 2px rgba(0,0,0,.45);
  transform-origin: 50% 130%;
}
.seat-name {
  font-weight: 700; font-size: 0.82em; line-height: 1.15; max-width: 108px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.seat-count { font-size: 0.7em; color: #c9d3e0; }
.seat.out { opacity: .55; }
.seat .bot-avatar { margin-right: 3px; }
/* You, at the near rim (your full hand is below the table). */
.me-seat {
  left: 50%; top: 100%; min-width: 0; padding: 4px 14px;
  background: #1c2536; border: 1px solid #3f2713;
}

/* Turn ring: a bright arc that orbits the active seat; faster + pulsing while
   that player is mid-move (drawn, not yet discarded). */
@property --orbit { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.seat.turn { box-shadow: 0 0 0 1px rgba(255,207,77,.45), 0 0 14px rgba(255,207,77,.28); }
.seat.turn::before {
  content: ''; position: absolute; inset: -5px; border-radius: 20px; padding: 3px;
  background: conic-gradient(from var(--orbit), rgba(255,207,77,0) 0deg, rgba(255,207,77,.18) 180deg, #ffcf4d 290deg, #fff3c4 320deg, rgba(255,207,77,0) 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: seatOrbit 2.8s linear infinite; pointer-events: none;
}
.seat.turn.mid-move { animation: seatPulse 1.1s ease-in-out infinite; }
.seat.turn.mid-move::before { animation-duration: 1.3s; }
@keyframes seatOrbit { to { --orbit: 360deg; } }
@keyframes seatPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,207,77,.45), 0 0 10px rgba(255,207,77,.25); }
  50%      { box-shadow: 0 0 0 2px rgba(255,207,77,.9), 0 0 26px rgba(255,207,77,.6); }
}
#your-area.my-turn #hand { border-radius: 12px; box-shadow: 0 0 0 2px rgba(255,207,77,.35); }

#center {
  position: absolute; left: 50%; top: 60%; transform: translate(-50%, -50%);
  display: flex; gap: 44px; justify-content: center; align-items: flex-start; margin: 0;
}
#table .pile { border-color: rgba(255,255,255,.22); background: rgba(0,0,0,.12); }
#table .pile-label { color: #f3efe2; }

/* Discard tray: the last few discards, face up, overlapping like coins. */
.discard-zone { display: flex; align-items: flex-start; }
.discard-tray { display: flex; align-items: flex-start; padding-top: 14px; margin-right: -14px; }
.discard-tray.empty { display: none; }
.tray-card {
  position: relative; width: 55px; height: 80px; margin-left: -28px; border-radius: 7px;
  background: #f7f3e9; border: 1px solid #d8cfb8; box-shadow: 0 1px 4px rgba(0,0,0,.45);
  transform: rotate(var(--tilt, 0deg)); color: #1a1d24; pointer-events: none;
  display: flex; flex-direction: column; align-items: flex-start; padding: 3px 4px;
}
.tray-card:first-child { margin-left: 0; }
.tray-card .tc-rank { font-weight: 800; font-size: 1em; line-height: 1; }
.tray-card .tc-emblem .emblem { width: 14px; height: 14px; }
.tray-card.oros { color: #c9971b; }
.tray-card.copas { color: #d23b3b; }
.tray-card.espadas { color: #2f6fd0; }
.tray-card.bastos { color: #2f9e54; }
.tray-card.has-wild { border-color: #c9971b; }
.discard-zone #discard { position: relative; z-index: 1; }

/* Big whose-turn marker. It sits ABOVE the piles in normal flow — deliberately
   not floated over them — so it can never cover a card, a meld, or a pile you
   are trying to tap. */
#turn-marker {
  margin: 2px auto 12px; width: fit-content; max-width: 94%;
  text-align: center;
  padding: 8px 18px; border-radius: 14px;
  background: rgba(17, 22, 29, 0.88); border: 2px solid var(--border);
  color: var(--dim); font-weight: 800; font-size: 1.55em;
  letter-spacing: .04em; text-transform: uppercase;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
/* It is YOUR turn: gold, high contrast, gently pulsing. */
#turn-marker.mine {
  color: #1a1d24; background: var(--accent); border-color: #fff3c4;
  animation: turnPulse 1.6s ease-in-out infinite;
}
@keyframes turnPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.pile {
  width: 96px; min-height: 140px; border: 1px dashed var(--border); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  color: var(--dim); font-size: 0.8em; text-align: center; padding: 8px 6px;
  gap: 8px; position: relative;
}
.pile-label { font-weight: 600; letter-spacing: .04em; color: var(--ink); }
.pile.tappable { cursor: pointer; border-color: var(--accent); border-style: solid; }
.pile.tappable:hover { transform: translateY(-3px); box-shadow: 0 6px 14px rgba(0,0,0,.28); }
.pile.disabled-pile { cursor: default; }
/* The stock may still dim when it is not tappable. The discard top stays
   full colour at all times (Nov 28, 2026). */
.pile-stock.disabled-pile { opacity: .5; }
#discard.disabled-pile { opacity: 1; }
.pile-stock .stock-stack { position: relative; width: 76px; height: 110px; }
.pile-stock .card-back {
  position: absolute; left: 0; width: 76px; height: 110px; border-radius: 10px;
  background: #f7f3e9 url("card-back.jpg") center/cover no-repeat;
  border: 1px solid #d8cfb8; box-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.pile-stock .card-back:nth-child(1) { top: 10px; left: 0; }
.pile-stock .card-back:nth-child(2) { top: 7px; left: 4px; }
.pile-stock .card-back:nth-child(3) { top: 3px; left: 8px; }
.pile-stock .card-back.top { top: 0; left: 12px; border-color: var(--accent); }
.stock-count {
  font-size: 1.9em; font-weight: 800; color: var(--card); line-height: 1;
  background: #11161d; border: 1px solid var(--border); border-radius: 8px;
  padding: 2px 10px; min-width: 44px;
}

#your-area h2 { margin: 18px 0 8px; }
#hand { display: flex; gap: 10px; flex-wrap: wrap; }
.card {
  width: 76px; height: 110px; background: #f7f3e9; border: 1px solid #d8cfb8;
  border-radius: 10px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; position: relative;
  cursor: pointer; user-select: none; color: #1a1d24;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.card:hover { border-color: var(--accent); transform: translateY(-3px); }
.card .rank {
  font-size: 2.1em; font-weight: 800; line-height: 1; letter-spacing: -1px;
}
.card .emblem-wrap { display: flex; align-items: center; justify-content: center; }
.card .emblem { width: 34px; height: 34px; }
/* Per-suit colour: Oros gold, Copas red, Espadas blue, Bastos green. */
.card.oros { color: #c9971b; }
.card.copas { color: #d23b3b; }
.card.espadas { color: #2f6fd0; }
.card.bastos { color: #2f9e54; }
.card .wild {
  position: absolute; top: 3px; right: 6px; color: #c9971b;
  font-size: 0.95em; text-shadow: 0 0 3px rgba(0,0,0,0.4);
}
.card.has-wild { border-color: #c9971b; }
.card.disabled { opacity: 0.5; cursor: default; filter: grayscale(0.2); }
.card.disabled:hover { border-color: #d8cfb8; transform: none; }

/* Discard pile: one full-size FACE-UP card (never a card back), in the same
   76x110 box as the stock, so both piles read as the same size. */
.discard-stack { position: relative; width: 76px; height: 110px; }

.discard-top {
  position: absolute; left: 0; top: 0; width: 76px; height: 110px; border-radius: 10px;
  background: #f7f3e9; border: 1px solid #d8cfb8; box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; user-select: none; color: #1a1d24;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.discard-top:hover { border-color: var(--accent); transform: translateY(-6px); box-shadow: 0 6px 14px rgba(0,0,0,0.28); }
.discard-top:active { transform: translateY(-2px); }
.discard-top .rank { font-size: 2.1em; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.discard-top .emblem-wrap { display: flex; align-items: center; justify-content: center; }
.discard-top .emblem { width: 34px; height: 34px; }
.discard-top.oros { color: #c9971b; }
.discard-top.copas { color: #d23b3b; }
.discard-top.espadas { color: #2f6fd0; }
.discard-top.bastos { color: #2f9e54; }
.discard-top.has-wild { border-color: #c9971b; }
.discard-top .wild { position: absolute; top: 3px; right: 6px; color: #c9971b; font-size: 0.95em; text-shadow: 0 0 3px rgba(0,0,0,0.4); }

/* When it's not your draw turn the discard top is not tappable, but it
   always stays in full colour (Nov 28, 2026). Hover lift is off so it
   does not look clickable. */
.pile.disabled-pile .discard-top { opacity: 1; filter: none; cursor: default; }
.pile.disabled-pile .discard-top:hover { border-color: #d8cfb8; transform: none; box-shadow: 0 2px 6px rgba(0,0,0,0.35); }

.meld { color: var(--dim); font-size: 0.9em; margin: 2px 0; }

#controls { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
#close-options .close-btn { background: #2e7d32; color: #fff; }
.close-prompt { width: 100%; color: var(--accent); font-weight: 700; margin: 6px 0 2px; }
.close-cancel { background: #3a3f4a; color: var(--ink); border: 1px dashed var(--accent); }

/* Lobby language selector and text links */
.sub-tab-link { background: none; border: none; color: var(--dim); text-decoration: underline; margin-top: 10px; }
.lang-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.lang-btn { background: #2a2f3a; color: var(--ink); padding: 4px 12px; border-radius: 14px; font-size: 0.85em; }
.lang-btn.active { background: var(--accent); color: #1a1d24; font-weight: 700; }

/* Lay-off board (Slice 2) */
#layoff-area { margin-top: 8px; }
#layoff-area h2 { margin: 6px 0; color: var(--accent); }
#layoff-cards-label { color: var(--dim); margin: 12px 0 6px; font-size: 0.9em; }
#layoff-hand { display: flex; gap: 10px; flex-wrap: wrap; min-height: 60px; margin: 8px 0; }
/* Selected (Nov 3, 2026, Dannel: the old 4px lift was too subtle): bigger,
   lifted, a thick gold outline with a white rim and a shadow. */
.card.selected {
  outline: 4px solid var(--accent); outline-offset: 1px;
  transform: translateY(-12px) scale(1.1);
  box-shadow: 0 0 0 2px #fff, 0 10px 20px rgba(0, 0, 0, 0.5);
  position: relative; z-index: 2;
}
/* Reorderable hand: tap a card to pick it up, tap another to swap. */
.card.reorderable { cursor: grab; }
.card.reorderable:hover { border-color: var(--accent); }
.card.picked { outline: 3px solid var(--accent); transform: translateY(-10px); box-shadow: 0 10px 22px rgba(0,0,0,.4); }
/* Locked 8th slot: the just-drawn card, awaiting the player's discard choice. */
.hand-sep { align-self: center; font-size: 1.6em; color: var(--accent); padding: 0 2px; }
.card.drawn-locked { outline: 2px dashed var(--accent); cursor: default; }
.card.drawn-locked:not(.clickable):hover { transform: none; border-color: #d8cfb8; }
#layoff-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* Game over (Slice 3) */
#gameover {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 12, 16, 0.78);
}
.go-card {
  background: #161a22; border: 1px solid var(--accent); border-radius: 16px;
  padding: 28px 34px; text-align: center; max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.go-card h2 { margin: 0 0 8px; color: var(--accent); }
.go-winner { font-size: 1.4em; font-weight: 700; margin: 6px 0 14px; }
#go-eliminated { margin-bottom: 18px; }
.go-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.go-board { margin: 10px 0 14px; text-align: left; }
.go-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 8px; }
.go-row.winner { background: rgba(255,207,77,0.14); font-weight: 700; }
.go-row.out { opacity: 0.5; }
.go-pending { margin: 4px 0 14px; font-weight: 600; color: var(--accent); }
.chat-msg.system { color: var(--accent); font-style: italic; }
.go-name { color: var(--ink); }
.go-score { color: var(--dim); font-variant-numeric: tabular-nums; }
.go-row.winner .go-score { color: var(--accent); }
/* Score badge (Nov 3, 2026): bold black number on a white circle / pill. */
.score-badge {
  display: inline-block; min-width: 1.9em; padding: 1px 7px; margin-left: 4px;
  border-radius: 999px; background: #fff; color: #000; font-weight: 800;
  font-size: 1.12em; line-height: 1.35; text-align: center; vertical-align: middle;
  font-variant-numeric: tabular-nums; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.go-score.score-badge, .go-row.winner .go-score.score-badge { color: #000; font-size: 1.2em; }
.go-row.winner .score-badge { box-shadow: 0 0 0 2px var(--accent); }
.row.out { opacity: 0.5; text-decoration: line-through; }

/* Connection status dots on the scoreboard */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-green { background: #2ecc71; box-shadow: 0 0 6px rgba(46,204,113,.6); }
.dot-red { background: #e74c3c; box-shadow: 0 0 6px rgba(231,76,60,.6); }

.banner { margin: 10px 0; padding: 10px 14px; border-radius: 10px; font-size: 0.95em; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.waiting { background: rgba(241,196,15,.12); border: 1px solid rgba(241,196,15,.5); color: var(--ink); }
.banner.spectator { background: rgba(231,76,60,.12); border: 1px solid rgba(231,76,60,.5); color: var(--ink); }
.banner.info { background: rgba(52,152,219,.12); border: 1px solid rgba(52,152,219,.5); color: var(--ink); justify-content: center; }
.banner button { margin: 0; }

/* Board top: room code sits above the scoreboard */
.board-top-row { display: flex; flex-direction: column; gap: 4px; }
#room-code-tag { font-size: 0.85em; letter-spacing: .06em; }
/* Waiting room: the host's room link + Copy link / Share. */
#share-link-row { display: flex; gap: 6px; align-items: center; max-width: 520px; margin-top: 6px; }
#share-link { flex: 1 1 auto; min-width: 0; margin: 0; }
#share-link-row button { margin: 0; flex: 0 0 auto; }

/* Per-room chat: a round bubble pinned (fixed) to the bottom-right corner of
   the table box, outside the oval felt, so it never covers the hand, the
   piles or the controls. --cb-right / --cb-bottom are set from the table's
   box by placeChatBubble(). Tapping it opens the chat as a panel floating
   above the table, right-aligned with the bubble. z 60 > game-over (50). */
#game { position: relative; }
.chat-bubble {
  position: fixed; right: var(--cb-right, 12px); bottom: var(--cb-bottom, 12px); z-index: 60;
  width: 52px; height: 52px; margin: 0; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #1a1d24; border: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 4px 14px rgba(0,0,0,.45); cursor: pointer;
}
.chat-bubble.active { box-shadow: 0 0 0 3px rgba(255,207,77,.45), 0 4px 14px rgba(0,0,0,.45); }
.chat-badge {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: #e74c3c; color: #fff; border: 2px solid #1a1d24;
  font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; box-sizing: border-box;
}
#chat { position: fixed; z-index: 60; display: none;
  right: var(--cb-right, 12px); bottom: calc(var(--cb-bottom, 12px) + 60px);
  width: min(320px, calc(100vw - 16px)); max-height: calc(100dvh - var(--cb-bottom, 12px) - 68px);
  flex-direction: column; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px;
  background: rgba(26, 29, 36, 0.96); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
#chat.open:not(.hidden) { display: flex; }
.chat-close { margin: 0 0 0 6px; padding: 0 8px; font-size: 1.3em; line-height: 1.2; background: transparent; border: 0; color: var(--ink); cursor: pointer; }
#chat .chat-head > span { flex: 1 1 auto; }
#chat #btn-chat-send { margin: 0; }
.chat-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 6px; }
#chat-log { max-height: 140px; min-height: 0; flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; font-size: 0.9em; }
.chat-msg { line-height: 1.3; }
.chat-name { color: var(--accent); font-weight: 600; }
.chat-text { color: var(--ink); }
#chat-input { width: 100%; margin-top: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: rgba(17, 22, 29, 0.7); color: var(--ink); }

/* ---------- animations (transform/opacity only, edge-triggered) ---------- */
.card { transition: transform .12s ease, box-shadow .12s ease; }
.card.clickable:hover { transform: translateY(-6px); box-shadow: 0 6px 14px rgba(0,0,0,.28); }
.card.clickable:active { transform: translateY(-2px); }
button { transition: transform .1s ease, background .15s ease, box-shadow .15s ease; }
button:hover:not(:disabled) { transform: translateY(-1px); }

@keyframes dealIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
#hand.deal-anim .card { animation: dealIn .26s ease both; }
/* While the deck is shuffled, nobody's new cards show yet. */
#table.dealing #hand .card, #table.dealing .seat-fan { visibility: hidden; }
#hand.deal-anim .card:nth-child(2) { animation-delay: .04s; }
#hand.deal-anim .card:nth-child(3) { animation-delay: .08s; }
#hand.deal-anim .card:nth-child(4) { animation-delay: .12s; }
#hand.deal-anim .card:nth-child(5) { animation-delay: .16s; }
#hand.deal-anim .card:nth-child(6) { animation-delay: .20s; }
#hand.deal-anim .card:nth-child(7) { animation-delay: .24s; }
#hand.deal-anim .card:nth-child(2) { animation-delay: .04s; }
#hand.deal-anim .card:nth-child(3) { animation-delay: .08s; }
#hand.deal-anim .card:nth-child(4) { animation-delay: .12s; }
#hand.deal-anim .card:nth-child(5) { animation-delay: .16s; }
#hand.deal-anim .card:nth-child(6) { animation-delay: .20s; }
#hand.deal-anim .card:nth-child(7) { animation-delay: .24s; }

@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
/* Discard top: any NEW top slides in (this selector was missing, so opponent
   discards animated nothing); YOUR OWN discard gets a throw-pop instead. Both
   are transform/opacity only and edge-triggered from render() via onceAnimate. */
.discard-top.slide-in { animation: slideIn .22s ease both; }
@keyframes throwToDiscard {
  from { opacity: 0; transform: translateY(-18px) scale(1.06) rotate(-3deg); }
  to   { opacity: 1; transform: none; }
}
.discard-top.thrown { animation: throwToDiscard .24s cubic-bezier(0.22, 0.61, 0.36, 1) both; }

/* Promote to a composited GPU layer ONLY while animating (transient classes),
   never on idle .card nodes — a permanent will-change would leak layers across
   7-8 cards x every seat. The layer is created on class-add and dropped on
   animationend (onceAnimate removes the class). */
#hand.deal-anim .card,
.discard-top.slide-in,
.discard-top.thrown,
.close-options.appear,
#layoff-area.appear,
#gameover.appear { will-change: transform, opacity; }

@keyframes panelIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.close-options.appear, #layoff-area.appear, #gameover.appear { animation: panelIn .25s ease both; }

@keyframes glow { 0% { box-shadow: 0 0 0 rgba(124,77,255,0); } 50% { box-shadow: 0 0 14px rgba(124,77,255,.6); } 100% { box-shadow: 0 0 0 rgba(124,77,255,0); } }
.meld.glow { animation: glow 1s ease both; }

/* Narrow close hint: a run that forms on the spot. Visible ~10s, then fades. */
.run-hint {
  margin: 8px 0 2px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: rgba(124, 77, 255, 0.08);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95em;
}
/* 10s lifespan: hold full for 8s, fade over the last 2s, then JS hides it. */
@keyframes runHintLife {
  0% { opacity: 0; transform: translateY(-6px); }
  5% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}
.run-hint.show { animation: runHintLife 10s ease forwards; }

/* Learning rooms: a bigger, didactic banner that lists the possible close(s).
   It persists (no 10s fade) so a newcomer can study it. */
.run-hint.learning {
  font-size: 1.25em;
  padding: 14px 18px;
  border-width: 2px;
  background: rgba(124, 77, 255, 0.16);
  animation: none; /* persist while the close is available */
}
@media (prefers-reduced-motion: reduce) {
  .run-hint.learning { animation: none !important; opacity: 1 !important; }
}

@media (prefers-reduced-motion: reduce) {
  #turn-marker.mine,
  .card, button, .hand.deal-anim .card,
  .discard-top.slide-in, .discard-top.thrown, .seat.turn, .seat.turn::before,
  .close-options.appear, #layoff-area.appear, #gameover.appear, .meld.glow { animation: none !important; transition: none !important; will-change: auto; }
  /* The run hint must still be readable without motion: show it statically. */
  .run-hint.show { animation: none !important; opacity: 1 !important; }
}

/* ---------- mobile-friendly base: kill tap delay, zoom, blue flash ---------- */
* { -webkit-tap-highlight-color: transparent; }
button, .card, .pile, input { touch-action: manipulation; }
.card { user-select: none; -webkit-user-select: none; }

/* ---------- responsive: phones (<= 640px) ---------- */
@media (max-width: 640px) {
  #app { padding: 10px; }
  .panel { padding: 14px; border-radius: 12px; }

  /* Table: taller than wide-ish oval on a phone; piles sit lower so the far
     rim (opponents) stays clear. */
  #table { height: 420px; border-radius: 48% / 50%; margin: 10px auto 24px; }
  #center { gap: 16px; top: 67%; }
  .seat { min-width: 58px; max-width: 74px; padding: 3px 5px; }
  .seat-fan { width: 54px; height: 26px; }
  .mini-back { width: 15px; height: 23px; }
  .seat-name { font-size: 0.72em; max-width: 66px; }
  .seat-count { font-size: 0.62em; }
  .tray-card { width: 40px; height: 60px; margin-left: -22px; }
  .discard-tray .tray-card:nth-last-child(4) { display: none; }
  .discard-tray .tray-card:nth-last-child(3) { margin-left: 0; }
  .pile { width: 84px; min-height: 118px; }
  .stock-count { font-size: 1.6em; }

  /* Hand: one swipeable row so all 8 cards stay big and tappable (no ugly wrap). */
  #hand { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; gap: 8px; }
  #hand .card { flex: 0 0 auto; }
  .card { width: 76px; height: 110px; }
  .card .rank { font-size: 2em; }
  .card .emblem { width: 32px; height: 32px; }
  .hand-sep { font-size: 1.4em; padding: 0 1px; }

  /* Opponents + scoreboard stack and shrink. */
  #scoreboard { font-size: 0.82em; display: flex; flex-wrap: wrap; gap: 0 12px; }

  /* Close buttons share one row (short labels). */
  #close-options { display: flex; flex-wrap: wrap; gap: 6px; }
  #close-options .close-btn, #close-options .close-cancel { flex: 1 1 auto; margin: 0; }

  #game { position: static; }

  /* Global lobby */
  .lobby-enter { display: flex; flex-direction: column; gap: 12px; align-items: stretch; justify-content: center; margin: 14px 0; max-width: 360px; }
  .lobby-enter input { margin-top: 0; }
  /* Three separate stacked panels instead of one cramped square. */
  .lobby-panel {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
    border-radius: 12px; padding: 14px 16px; margin: 14px 0;
  }
  .lobby-panel h3 { margin: 0 0 10px; color: var(--accent); }
  #lobby-title { margin: 6px 0 0; letter-spacing: 2px; color: var(--accent); }
  ul.members { list-style: none; margin: 0 0 12px; padding: 0; }
  ul.members li { padding: 5px 9px; border-radius: 8px; background: rgba(255,255,255,0.04); margin-bottom: 5px; }
  .lobby-actions { display: flex; gap: 10px; }

/* Blue "Gameplay" info button (lobby, beside the red Leave button). */
  .info {
    background: linear-gradient(135deg, #1e88e5, #1565c0);
    color: #fff;
    border: none;
  }
  .info:hover { filter: brightness(1.1); }

  /* Black full-screen rules reference (opens from the lobby). */
  #gameplay { background: #000; }
  .gameplay-screen {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px 60px;
    color: #f2f2f2;
  }
  .gameplay-screen h1 {
    color: #fff;
    letter-spacing: 1px;
    margin: 14px 0 22px;
    text-align: center;
  }
  .gameplay-rules { display: flex; flex-direction: column; gap: 18px; }
  .rule-block { line-height: 1.6; }
  .rule-block .rule-title {
    font-weight: 700;
    color: var(--accent);
    display: block;
    margin-bottom: 4px;
    font-size: 1.05em;
  }
  .rule-block .rule-body { color: #e6e6e6; }

  /* Tutorial rule prompt (shown each novice turn before they may act). */
  .tutorial-rule {
    background: rgba(124, 77, 255, 0.12);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 16px 18px;
    margin: 12px 0;
    max-width: 720px;
  }
  .tutorial-rule-title { font-weight: 700; color: var(--accent); font-size: 1.1em; margin-bottom: 6px; }
  .tutorial-rule-body { line-height: 1.6; margin-bottom: 12px; }
  /* General chat panel */
  .chat-send-row { display: flex; gap: 8px; margin-top: 8px; }
  #lobby-chat-input { width: calc(100% - 70px); margin-right: 0; }
  .lobby-panel .chat-log { max-height: 180px; height: 180px; overflow-y: auto; }
  /* Room-setup: create choices, private dialogue, room-info waiting view */
  #create-choices { display: flex; flex-direction: column; gap: 10px; max-width: 320px; }
  #create-choices .primary { width: 100%; }

  /* Close/Continue offer (human's discard turn, when a legal close exists). */
  .close-offer {
    margin: 14px auto;
    max-width: 560px;
    background: rgba(124, 77, 255, 0.14);
    border: 2px solid rgba(124, 77, 255, 0.6);
    border-radius: 14px;
    padding: 16px 18px;
    text-align: center;
  }
  .close-offer-text { font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; color: #fff; }
  .close-offer-actions { display: flex; gap: 12px; justify-content: center; }

  /* Flash highlight when the Close/Continue "Close" button focuses the close options. */
  #close-options.flash { animation: coflash 0.7s ease; }
  @keyframes coflash { 0% { box-shadow: 0 0 0 0 rgba(124,77,255,0.9); } 100% { box-shadow: 0 0 0 14px rgba(124,77,255,0); } }
  #pd-bots-count { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; max-width: 200px; }
  #room-info { margin-top: 14px; }
  #room-info .code { font-weight: 800; letter-spacing: 2px; color: var(--accent); font-size: 1.2em; }
  #room-waiting { margin: 6px 0; color: var(--dim); }
  .lobby-actions .small { margin-top: 0; }
}

/* Gameplay overlay language toggle (EN / ES). */
.lang-toggle { display: flex; gap: 8px; margin: 10px 0 4px; }
.lang-btn { padding: 6px 16px; border-radius: 999px; border: 1px solid var(--accent); background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }
.lang-btn.active { background: var(--accent); color: #14161c; }

/* Lobby header: title left, small Rules pill right (next to Leave). */
.lobby-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lobby-header h1 { margin: 0; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.top-pill {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--accent);
  background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.top-pill:hover { background: rgba(124,77,255,0.12); }
.danger-pill { border-color: #ff5a5a; color: #ff7a7a; }
.danger-pill:hover { background: rgba(255,90,90,0.14); }

/* "Start tutorial match" button at the foot of the rules overlay. */
.gameplay-tutorial-btn { margin: 18px auto 4px; display: block; }

/* Bot avatar chip (emoji on the bot's color) shown next to opponent names. */
.bot-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.5em; height: 1.5em; border-radius: 50%;
  margin-right: 6px; font-size: 0.85em; vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}

/* Reduced motion: the turn ring becomes a static, full highlight. */
@media (prefers-reduced-motion: reduce) {
  .seat.turn::before { background: #ffcf4d; animation: none !important; }
  .seat.turn, .seat.turn.mid-move { animation: none !important; }
  .seat.turn.mid-move { box-shadow: 0 0 0 2px rgba(255,207,77,.9), 0 0 18px rgba(255,207,77,.5); }
}

/* ======================================================================
   Fit to the viewport (Oct 5, 2026). The game screen never scrolls the
   page: on desktop and on phones in portrait AND landscape the whole board
   (header, scores, turn marker, table, hand) sits inside
   100dvh. Layout/sizing only: the table flexes, and the piles, seats and
   hand cards scale with the space they get (container query units), so the
   look is unchanged. The lobby, landing and waiting screens fit too.
   ====================================================================== */

/* ---- Game screen: one full-height column; only the table flexes. ---- */
/* Nov 29, 2026: pin the game to the viewport (100dvh, no rubber-band, no
   accidental pinch / double-tap zoom). Reserved south slots keep the felt
   and the hand from jumping between play, arrange, and round-end. */
#app:has(> #game:not(.hidden)) {
  padding-top: 8px; padding-bottom: 8px;
  height: 100vh; height: 100dvh; max-height: 100dvh;
  overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
  box-sizing: border-box;
}
#game {
  margin-top: 0; padding: 12px 16px;
  display: flex; flex-direction: column;
  height: calc(100vh - 16px); height: calc(100dvh - 16px);
  max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px);
  overflow-x: hidden; overflow-y: auto; /* last-resort inner scroll; the page itself never scrolls */
  overscroll-behavior: none;
  touch-action: manipulation;
}
#game > * { flex-shrink: 0; min-width: 0; }

/* Header: room code + Leave on one line, the scores wrap underneath. */
.board-top-row { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 12px; width: 100%; }
#room-code-tag { order: 0; }
#btn-leave-match { order: 2; margin: 0 0 0 auto; }
#scoreboard { order: 3; flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 0 14px; }
#scoreboard .row { margin: 1px 0; }
#turn-marker {
  margin: 2px auto 6px;
  padding: clamp(3px, 0.9dvh, 8px) 18px;
  font-size: clamp(1.05em, 3.3dvh, 1.55em);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* The table takes whatever height is left (never taller than before). It is a
   size container, so the piles and seats inside scale with it. */
#game > #table {
  flex: 1 1 430px; height: auto; min-height: 160px; margin: 6px auto 18px;
  container: table / size;
}
#center {
  --pc-h: clamp(50px, min(30cqh, 28cqw), 110px);  /* pile card height (110px max, ~15% up) */
  --pc-w: calc(var(--pc-h) * 0.6875);
  gap: clamp(12px, 5.5cqw, 44px);
}
#center .pile { width: calc(var(--pc-w) + 30px); min-height: 0; padding: clamp(4px, 1.8cqh, 8px) 6px; gap: clamp(3px, 1.6cqh, 8px); }
#center .pile-stock .stock-stack,
#center .discard-stack,
#center .pile-stock .card-back,
#center .discard-top { width: var(--pc-w); height: var(--pc-h); }
#center .discard-top { gap: calc(var(--pc-h) * 0.04); }
#center .discard-top .rank { font-size: calc(var(--pc-w) * 0.5); }
#center .discard-top .emblem { width: calc(var(--pc-w) * 0.5); height: calc(var(--pc-w) * 0.5); }
#center .stock-count { font-size: calc(var(--pc-h) * 0.3); padding: 1px 8px; min-width: calc(var(--pc-h) * 0.46); }
#center .discard-tray { padding-top: calc(var(--pc-h) * 0.146); }
#center .tray-card { width: calc(var(--pc-w) * 0.727); height: calc(var(--pc-h) * 0.73); margin-left: calc(var(--pc-w) * -0.36); }
#center .tray-card:first-child { margin-left: 0; }
/* Small table (phones, short screens): the compact seat size phones already use. */
@container table (max-width: 560px) or (max-height: 330px) {
  .seat { min-width: 58px; max-width: 74px; padding: 3px 5px; }
  .seat-fan { width: 54px; height: 26px; }
  .mini-back { width: 15px; height: 23px; }
  .seat-name { font-size: 0.72em; max-width: 66px; }
  .seat-count { font-size: 0.62em; }
  .me-seat { padding: 3px 12px; }
}

/* Hand: one row. Cards size themselves to the row width (8 cards + the drawn-
   card arrow always fit), between 36px and the full 76px. If a row is ever
   narrower than that (8 cards at 36px), the hand swipes sideways inside itself. */
#south { position: relative; flex-shrink: 0; min-width: 0; }
#action-slot {
  min-height: 72px;
  display: flex; flex-direction: column; justify-content: center;
}
#arrange-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
}
#your-area { container: hand / inline-size; }
#your-area h2 { margin: 4px 0 2px; font-size: clamp(1.05em, 2.6dvh, 1.5em); }
#hand {
  --hgap: clamp(3px, 1cqw, 10px);
  --hc-w: clamp(36px, calc((100cqw - 8 * var(--hgap) - 4px) / 8.2), 76px);
  flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; gap: var(--hgap);
  padding: 10px 2px 6px; -webkit-overflow-scrolling: touch;
  min-height: calc(var(--hc-w) * 1.4545 + 16px);
}
#south:has(> #round-end:not(.hidden)) > #your-area,
#south:has(> #round-end:not(.hidden)) > #controls,
#south:has(> #round-end:not(.hidden)) > #status {
  visibility: hidden; pointer-events: none;
}
#south:has(> #round-end:not(.hidden)) > #round-end {
  position: absolute; inset: 0; margin: 0; max-width: none; width: 100%;
  overflow: hidden; overscroll-behavior: none;
  display: flex; flex-direction: column; justify-content: flex-start;
  box-sizing: border-box; padding: 2px 8px 4px;
}
#south:has(> #round-end:not(.hidden)) > #round-end .re-board {
  flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: none; margin-bottom: 4px;
}
#south:has(> #round-end:not(.hidden)) > #round-end #btn-next-round {
  flex-shrink: 0; margin: 0 auto 2px;
}
#controls:empty { display: none; margin: 0; }
#hand .card {
  flex: 0 0 auto; width: var(--hc-w); height: calc(var(--hc-w) * 1.4545);
  gap: calc(var(--hc-w) * 0.06);
}
/* Nov 8, 2026 (Dannel): the hand sits centred in the tray as one group (the
   drawn-card arrow and card included). Auto margins on the ends, not
   justify-content: center, so an overflowing row still scrolls from its first
   card instead of clipping the left edge. */
#hand > :first-child { margin-left: auto; }
#hand > :last-child { margin-right: auto; }
#hand .card .rank { font-size: calc(var(--hc-w) * 0.485); }
#hand .card .emblem { width: calc(var(--hc-w) * 0.5); height: calc(var(--hc-w) * 0.5); }
#hand .hand-sep { flex: 0 0 auto; width: calc(var(--hc-w) * 0.4); padding: 0; text-align: center; font-size: calc(var(--hc-w) * 0.36); }
#controls { margin-top: 4px; }
#game #status { margin: 0; min-height: 0; }
/* Game over / seat-reconnected cards stay reachable on short screens. */
.go-card { max-height: calc(100dvh - 16px); overflow-y: auto; }

/* Phones, portrait. */
@media (max-width: 640px) {
  #app:has(> #game:not(.hidden)) { padding: 4px; height: 100vh; height: 100dvh; max-height: 100dvh; }
  #game { height: calc(100vh - 8px); height: calc(100dvh - 8px); max-height: calc(100vh - 8px); max-height: calc(100dvh - 8px); padding: 8px 6px; }
  #game > #table { flex-basis: 420px; margin: 4px auto 16px; }
}

/* Very narrow portrait: reserve the taller header so a wrapped score row
   cannot shove the felt when names or totals grow (e.g. 360x740). */
@media (max-width: 380px) {
  #board-top { min-height: 130px; }
}

/* Phones, landscape (short screens): table on the left, everything else on
   the right. */
@media (orientation: landscape) and (max-height: 500px) {
  #app:has(> #game:not(.hidden)) {
    max-width: none;
    padding: 4px max(4px, env(safe-area-inset-right, 0px)) 4px max(4px, env(safe-area-inset-left, 0px));
  }
  #game {
    height: calc(100vh - 8px); height: calc(100dvh - 8px); max-height: none;
    padding: 6px 10px; border-radius: 12px;
    display: grid; column-gap: 12px;
    grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
    grid-template-rows: repeat(12, auto) minmax(0, 1fr);
    align-content: start;
  }
  #game > * { grid-column: 2; }
  #game > #table { grid-column: 1; grid-row: 1 / -1; width: 100%; max-width: none; height: auto; min-height: 0; margin: 0 0 14px; }
  #turn-marker { margin: 2px auto 4px; }
  #game #center { top: 66%; gap: clamp(10px, 4cqw, 44px); }
  #your-area h2 { margin: 2px 0 0; }
  #hand { padding-top: 8px; padding-bottom: 4px; }
  #scoreboard { font-size: 0.82em; gap: 0 12px; }
  #game > #table { max-height: calc(100dvh - 34px); }
  #close-options { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 0; }
  #close-options .close-prompt { margin: 2px 0 0; }
  #close-options .close-btn, #close-options .close-cancel { margin: 0; padding: 6px 10px; font-size: 0.9em; min-height: 44px; }
  #action-slot { min-height: 52px; }
  #arrange-row { flex-wrap: nowrap; gap: 6px 8px; }
  #closing-aside { margin: 0 0 2px; }
  #closing-aside .card { width: 36px; height: 52px; }
  #closing-aside .card .rank { font-size: 1.15em; }
  #closing-aside .card .emblem { width: 16px; height: 16px; }
  #close-actions { margin: 2px 0; }
  #table-voice { left: 6%; bottom: 2%; max-width: min(160px, 38%); }

}

/* ---- Lobby: fills the viewport; the player list and chat log
   scroll inside their own panels instead of growing the page. ---- */
#app:has(> #globby:not(.hidden) > #lobby-main:not(.hidden)) {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding-top: 8px; padding-bottom: 8px;
}
#globby:has(> #lobby-main:not(.hidden)) { margin-top: 0; flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
#globby:has(> #lobby-main:not(.hidden)) > :not(#lobby-main) { flex-shrink: 0; }
#globby > #lobby-main {
  flex: 0 1 auto; min-height: 0; display: grid;
  /* Short screen: the three panels share the height (none taller than its
     content, none shorter than its own min-height); the list / chat log
     scroll inside. */
  grid-template-rows: auto repeat(2, minmax(auto, max-content));
}
#lobby-main > section:nth-of-type(1) { min-height: 11.5em; display: flex; flex-direction: column; } /* title + 2 names + the room buttons */
#lobby-main > section:nth-of-type(1) > * { flex-shrink: 0; }
#lobby-main #lobby-members { flex: 0 1 auto; min-height: 2.6em; overflow-y: auto; }
/* Nov 29, 2026: the Active matches panel is gone; the chat is the 2nd panel. */
#lobby-main > section:nth-of-type(2) { min-height: 10em; display: flex; flex-direction: column; } /* title + 2 lines + the input row */
#lobby-main > section:nth-of-type(2) > * { flex-shrink: 0; }
#lobby-main #lobby-chat-log { flex: 0 1 auto; min-height: 2.6em; overflow-y: auto; }

/* ---- Phones, landscape: every screen loses the big top gap; the lobby
   goes two-column and the waiting list wraps into columns. ---- */
@media (orientation: landscape) and (max-height: 500px) {
  #app { padding-top: 6px; padding-bottom: 6px; }
  .panel { margin-top: 0; padding: 10px 14px; }
  #title { font-size: min(64px, 14vw, 11dvh); }
  .tagline { margin: 0 0 4px; }
  #globby:has(> #lobby-main:not(.hidden)) { flex: 1 1 auto; }
  /* Lobby: players (with the room buttons) on the left; header and chat on
     the right. */
  #globby > #lobby-main {
    flex: 1 1 auto; display: grid; column-gap: 14px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  #lobby-main > .lobby-header { grid-column: 2; grid-row: 1; }
  #lobby-title { font-size: 1.6em; margin: 0; }
  #lobby-main > section:nth-of-type(1) { grid-column: 1; grid-row: 1 / 3; }
  #lobby-main > section:nth-of-type(2) { grid-column: 2; grid-row: 2; min-height: 0; overflow: hidden; }
  #lobby-main .lobby-panel { margin: 4px 0; padding: 8px 12px; }
  #lobby-main .lobby-panel h3 { margin: 0 0 6px; }
  #lobby-main #lobby-members { flex: 1 1 auto; min-height: 2.6em; }
  #lobby-main #lobby-chat-log { flex: 1 1 0; height: auto; max-height: none; min-height: 1.4em; }
  #lobby-main .lobby-actions { flex-wrap: wrap; gap: 6px; }
  #lobby-main .lobby-actions button { margin: 0; padding: 7px 12px; }
  #lobby-main .chat-send-row { display: flex; gap: 8px; margin-top: 4px; }
  #lobby-main .chat-send-row input { margin-top: 0; }
  #lobby-main .chat-send-row button { margin: 0; }
  /* Waiting room */
  #room-info { margin-top: 4px; }
  #room-info p { margin: 4px 0; }
  ul#lobby-players { columns: 3; margin: 4px 0; }
  #lobby .share-buttons button, #btn-host-start, #btn-back-lobby { margin-top: 4px; }
}

/* ======================================================================
   Card-based close + lay-off melds on the felt (Oct 8, 2026).
   The closer taps Close, puts their own cards into melds (face up on the
   felt), then picks the discard. During the lay-off every table meld sits
   on the felt with the seat that laid it; tap one to attach a card. The
   piles are hidden meanwhile. Felt cards shrink (JS: fitFelt) until every
   meld fits inside the felt, so nothing scrolls.
   ====================================================================== */
#felt-melds {
  --fm-w: 58px;
  position: absolute; left: 12%; right: 12%; top: 29%; bottom: 9%;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center;
  gap: calc(var(--fm-w) * 0.3) calc(var(--fm-w) * 0.4);
  overflow: hidden;
}
#table.melds-mode #center { display: none; }
.felt-meld {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 3px 5px 5px; border-radius: 8px; background: rgba(8, 16, 32, 0.38);
}
.felt-meld.mine { background: rgba(8, 16, 32, 0.55); }
/* R42 (Nov 3, 2026, Dannel: "the -10 melds make the around it red so people
   know that those are the melds no one could feed"). Only the -10-locked melds;
   full opacity and a bright red edge plus glow so it reads on the blue felt. */
.felt-meld.locked {
  border: 2px solid #ff3b30;
  box-shadow: 0 0 0 1px rgba(255, 59, 48, 0.55), 0 0 12px 2px rgba(255, 59, 48, 0.55);
}
.felt-meld.locked .fm-owner { color: #ffd6d3; }
.felt-meld.tappable { cursor: pointer; box-shadow: 0 0 0 1px rgba(255, 207, 77, 0.55); }
.fm-owner {
  font-size: clamp(9px, calc(var(--fm-w) * 0.27), 12px); line-height: 1.1; color: #f3efe2;
  max-width: calc(var(--fm-w) * 3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fm-cards { display: flex; }
.fm-card {
  position: relative; width: var(--fm-w); height: calc(var(--fm-w) * 1.45);
  margin-left: calc(var(--fm-w) * -0.4); border-radius: calc(var(--fm-w) * 0.14);
  background: #f7f3e9; border: 1px solid #d8cfb8; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  color: #1a1d24; display: flex; flex-direction: column; align-items: flex-start;
  padding: calc(var(--fm-w) * 0.06) calc(var(--fm-w) * 0.08);
}
.fm-card:first-child { margin-left: 0; }
.fm-card.tappable { cursor: pointer; touch-action: manipulation; }
.fm-card .tc-rank { font-weight: 800; font-size: calc(var(--fm-w) * 0.42); line-height: 1; }
.fm-card .emblem { width: calc(var(--fm-w) * 0.36); height: calc(var(--fm-w) * 0.36); }
.fm-card.oros { color: #c9971b; }
.fm-card.copas { color: #d23b3b; }
.fm-card.espadas { color: #2f6fd0; }
.fm-card.bastos { color: #2f9e54; }
.fm-card.has-wild { border-color: #c9971b; }
.felt-empty {
  padding: 8px 14px; border: 1px dashed rgba(243, 239, 226, 0.5); border-radius: 10px;
  color: rgba(243, 239, 226, 0.8); font-size: 0.85em;
}
/* R24 false close: the would-be closer's hand, face up, above the table. */
#false-close {
  --fm-w: 30px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px;
  margin: 0 auto 4px; padding: 3px 10px; border-radius: 10px;
  background: rgba(210, 59, 59, 0.18); border: 1px solid rgba(210, 59, 59, 0.55);
  color: #ffd7d7; font-size: 0.85em;
}
#false-close .fc-cards { display: flex; gap: 2px; }
#false-close .fm-card { margin-left: 0; }
/* Lay-off: your remaining cards use the same one-row sizing as the hand. */
#layoff-area { container: layoffhand / inline-size; margin-top: 2px; }
#layoff-area h2 { margin: 2px 0; font-size: clamp(1.05em, 2.6dvh, 1.5em); }
#layoff-cards-label { margin: 2px 0; }
#layoff-hand {
  --hgap: clamp(3px, 1cqw, 10px);
  --hc-w: clamp(36px, calc((100cqw - 8 * var(--hgap) - 4px) / 8.2), 76px);
  flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; gap: var(--hgap);
  min-height: 0; margin: 0; padding: 10px 2px 6px;
}
#layoff-hand .card {
  flex: 0 0 auto; width: var(--hc-w); height: calc(var(--hc-w) * 1.4545);
  gap: calc(var(--hc-w) * 0.06);
}
#layoff-hand .card .rank { font-size: calc(var(--hc-w) * 0.485); }
#layoff-hand .card .emblem { width: calc(var(--hc-w) * 0.5); height: calc(var(--hc-w) * 0.5); }
#layoff-controls { margin-top: 4px; gap: 6px 10px; }
#close-options .close-prompt { font-size: 0.85em; font-weight: 600; margin: 2px 0; }
/* Phones in landscape: the right column is short, so the close-mode help and
   the lay-off header/buttons go compact (one row of buttons). */
@media (orientation: landscape) and (max-height: 500px) {
  #close-options .close-prompt { font-size: 0.72em; line-height: 1.2; margin: 0; }
  #close-options .close-btn, #close-options .close-cancel { padding: 4px 10px; }
  #layoff-area h2 { font-size: 1em; margin: 0; }
  #layoff-cards-label { display: none; }
  #layoff-hand { padding-top: 6px; padding-bottom: 2px; }
  #layoff-controls { margin-top: 2px; gap: 4px 6px; }
  #layoff-controls button { margin: 0; padding: 5px 10px; font-size: 0.85em; }
  #layoff-status { font-size: 0.8em; }
}

/* Watched turns (Oct 8, 2026): a card travelling between the stock, the
   discard and a seat. Transform only. It never takes a tap, and the hand
   sits above it so a flight cannot cover or block your cards. */
.fly-card {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 46px; height: 66px; border-radius: 6px; background: #f7f3e8; color: #222;
  box-shadow: 0 8px 18px rgba(0,0,0,.4); font-weight: 800;
}
.fly-card.face-down { background: #163828; }
.fly-card .fly-back {
  width: 70%; height: 74%; border-radius: 3px;
  background: repeating-linear-gradient(45deg, #1d4e3a, #1d4e3a 4px, #245c44 4px, #245c44 8px);
  border: 1px solid #d4af37;
}
.fly-card .rank { font-size: 18px; line-height: 1; }
.fly-card .emblem-wrap { width: 18px; height: 18px; }
.fly-card .emblem-wrap svg { width: 100%; height: 100%; }
.fly-card.oros { color: #c9971b; }
.fly-card.copas { color: #d23b3b; }
.fly-card.espadas { color: #2f6fd0; }
.fly-card.bastos { color: #2f9e54; }
#your-area, #controls, #layoff-area { position: relative; z-index: 36; }
@media (prefers-reduced-motion: reduce) {
  .fly-card { transition: none !important; }
}

/* Voice-call link (Nov 3, 2026): waiting-room field + in-game button.
   Nov 28, 2026: a compact control also sits on the felt so any player can
   paste or change a link mid-game without growing the page. */
.voice-link-row { margin: 10px 0; }
.voice-link-row label { display: block; font-size: 0.9em; color: var(--dim); margin-bottom: 4px; }
#voice-link-input, #table-voice-input { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: #11141a; color: var(--ink); }
.voice-call {
  display: inline-block; padding: 3px 10px; border-radius: 14px; font-size: 0.82em; font-weight: 700;
  background: #2ecc71; color: #0f1115; text-decoration: none; white-space: nowrap;
}
#table-voice {
  position: absolute; left: 10%; bottom: 2%; z-index: 8;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  max-width: min(190px, 36%); pointer-events: auto;
}
#table-voice.hidden { display: none; }
#table-voice .voice-call { font-size: 0.72em; padding: 3px 7px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#table-voice .tv-edit-btn { margin: 0; padding: 2px 7px; font-size: 0.68em; line-height: 1.2; }
#table-voice-edit { display: flex; gap: 4px; width: 100%; }
#table-voice-edit.hidden { display: none; }
#table-voice-input { padding: 4px 6px; font-size: 0.78em; }
#table-voice-msg { margin: 0; font-size: 0.7em; max-width: 100%; text-align: left; color: #f3efe2; }
@media (max-width: 640px) {
  #table-voice { left: 8%; bottom: 2%; max-width: min(170px, 40%); }
  #table-voice .voice-call { font-size: 0.66em; padding: 2px 6px; }
}
/* Closing discard marker (Nov 3, 2026): the card Discard & close will throw. */
.card.close-discard { position: relative; outline: 3px solid #e74c3c; transform: translateY(-8px); }
.card.close-discard::after {
  content: attr(data-tag); position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%);
  background: #e74c3c; color: #fff; font-size: 10px; font-weight: 800; padding: 1px 6px;
  border-radius: 8px; white-space: nowrap; pointer-events: none; letter-spacing: .02em;
}

/* Closing marker (Nov 3, 2026, Dannel: "place a distinctive marker when someone
   is in the process of closing"). Pulsing gold badge over the closing seat. */
.seat.closing .seat-name { box-shadow: 0 0 0 2px #f5c542, 0 0 14px rgba(245, 197, 66, 0.8); border-radius: 999px; }
.closing-badge {
  position: absolute; left: 50%; top: -22px; transform: translateX(-50%);
  white-space: nowrap; padding: 2px 9px; border-radius: 999px;
  background: #f5c542; color: #1c1300; font-weight: 800; font-size: 0.78rem;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 0 12px rgba(245, 197, 66, 0.9);
  animation: closing-pulse 1.1s ease-in-out infinite; z-index: 3; pointer-events: none;
}
@keyframes closing-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 6px rgba(245,197,66,.6); }
  50% { transform: translateX(-50%) scale(1.08); box-shadow: 0 0 0 2px rgba(0,0,0,.35), 0 0 18px rgba(245,197,66,1); }
}
@media (prefers-reduced-motion: reduce) { .closing-badge { animation: none; } }

/* Close mode: the hand row clips vertically (overflow-x scroll), so leave room
   above for the lifted, scaled selected card. The Discard / Close actions live
   in a fixed bar above the hand (Nov 28, 2026), not on the card, so they no
   longer need extra row padding. */
#hand.close-mode, #hand.close-pick { padding-top: 10px; padding-left: 2px; padding-right: 2px; }
#closing-aside {
  display: flex; align-items: center; gap: 8px;
  margin: 0; min-height: 0;
}
#closing-aside.hidden { display: none; }
#closing-aside .aside-label { color: var(--dim); font-size: 0.85em; }
#closing-aside .card { width: 50px; height: 72px; gap: 2px; pointer-events: none; transform: none; }
@media (orientation: landscape) and (max-height: 500px) {
  #action-slot { min-height: 52px; }
  #arrange-row { flex-wrap: nowrap; gap: 6px 8px; }
  #closing-aside { margin: 0; }
  #closing-aside .card { width: 36px; height: 52px; }
  #closing-aside .card .rank { font-size: 1.15em; }
  #closing-aside .card .emblem { width: 16px; height: 16px; }
}
#closing-aside .card .rank { font-size: 1.45em; }
#closing-aside .card .emblem { width: 22px; height: 22px; }
#close-actions {
  display: flex; flex-wrap: wrap; align-items: stretch; justify-content: space-between;
  gap: 10px 20px; margin: 0;
}
#close-actions.hidden { display: none; }
#close-actions .close-act {
  display: flex; flex-wrap: wrap; align-items: stretch; justify-content: space-between;
  gap: 10px 20px; width: 100%;
}
#close-actions .close-why {
  flex: 1 1 100%; font-size: 0.85em; line-height: 1.25; text-align: center; color: #f0d28a;
  margin: 0;
}
#close-actions .close-plain,
#close-actions .close-btn {
  flex: 1 1 0; min-width: 120px; min-height: 44px; margin: 0;
  padding: 10px 16px; font-size: 1em; font-weight: 800; line-height: 1.2;
}
#close-actions .close-plain {
  background: #2a3342; color: #f3efe2; border: 1px solid var(--border);
}
#close-actions .close-btn {
  background: #2e7d32; color: #fff; border: 1px solid #4caf50;
  box-shadow: 0 0 0 1px rgba(76, 175, 80, 0.35);
}
#close-actions .close-btn:disabled { opacity: 0.45; }
#close-options { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
#arrange-row #close-options { flex: 1 1 auto; justify-content: flex-end; gap: 8px 12px; }
#arrange-row #close-options .close-btn,
#arrange-row #close-options .close-cancel { flex: 1 1 0; min-width: 100px; }
#arrange-row #close-options .close-prompt { flex: 1 1 100%; margin: 0; font-size: 0.8em; }
#close-options .close-btn,
#close-options .close-cancel {
  min-height: 44px; margin: 0; padding: 10px 16px; font-size: 1em; font-weight: 700;
}
#close-options .close-cancel { background: transparent; border: 1px solid var(--border); color: var(--ink); }

/* Game over OVER the table (Nov 3, 2026, Dannel): no full-screen backdrop, no
   cut away. The panel floats on the felt; the last melds, the piles, your hand
   and the chat bubble stay visible and usable around it. */
#table > #gameover {
  position: absolute; inset: 0; z-index: 40; background: none;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
#table > #gameover.hidden { display: none; }
#table > #gameover .go-card {
  pointer-events: auto; width: min(88%, 380px); max-height: 94%; overflow-y: auto;
  padding: 14px 18px; background: rgba(22, 26, 34, 0.9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
#table > #gameover .go-card h2 { margin: 0 0 4px; }
#table > #gameover .go-board { margin: 6px 0 8px; }
#table > #gameover #go-eliminated { margin-bottom: 10px; }

/* Round-over pause (Nov 8, 2026) */
.round-end { text-align: center; margin: 6px auto; padding: 8px 10px; max-width: 640px; }
.round-end h3 { margin: 2px 0 6px; }
.re-board { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.re-row { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; }
.re-row .re-name { font-weight: 600; min-width: 5em; text-align: right; }
.re-cards { display: flex; gap: 3px; }
.re-cards .card { width: 34px; height: 49px; flex: 0 0 auto; }
.re-cards .card .rank { font-size: 16px; }
.re-cards .card .emblem { width: 17px; height: 17px; }

/* Deck picker (waiting-room host + solo). Keyboard operable, same dark panel. */
.deck-picker {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0 0 12px;
  padding: 8px 10px 10px;
  max-width: 320px;
}
.deck-picker legend {
  padding: 0 6px;
  color: var(--dim);
  font-size: 0.85em;
}
.deck-options { display: flex; gap: 8px; }
.deck-option {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #11141a;
  color: var(--ink);
  font-size: 0.85em;
  cursor: pointer;
}
.deck-option input {
  /* Fixed box, not 100% of the label. A percentage height here cycles: the
     label sizes to its contents, and the radio was one of those contents. */
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}
.deck-option:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.deck-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.deck-name { font-weight: 600; text-align: center; }
.deck-thumb {
  width: 40px;
  height: 66px;
  border-radius: 6px;
  overflow: hidden;
  background: #f7f3e9;
  border: 1px solid #d8cfb8;
}
.deck-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.deck-thumb-classic {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #c9971b;
}
.dt-rank { font-weight: 800; font-size: 16px; line-height: 1; }
.dt-coin {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; box-sizing: border-box;
  background: radial-gradient(circle, currentColor 0 3px, transparent 3.5px);
}
.deck-option.locked {
  cursor: not-allowed;
  opacity: 0.55;
}
.deck-option.locked:focus-within { outline: none; }
.deck-lock {
  font-size: 0.75em;
  font-weight: 600;
  color: var(--dim);
}
.deck-option:not(.locked) .deck-lock { display: none; }
.room-deck-row { margin: 0 0 12px; }
.room-deck-chosen { margin: 0; color: var(--dim); }
.room-deck-row .deck-picker { margin-bottom: 0; }

/* Stained-glass faces fill the existing card boxes. The art is a little
   narrower than the slot, so a cream mat shows at the sides and the indices
   stay visible. Requested only when the room's deck is stained-glass. */
.sg-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  border-radius: inherit;
  user-select: none;
  -webkit-user-drag: none;
}
.card.sg, .discard-top.sg, .tray-card.sg, .fm-card.sg, .fly-card.sg {
  background: #f4f1ea;
  overflow: hidden;
}
.tray-card.sg, .fm-card.sg { padding: 0; }
.card.sg .wild, .discard-top.sg .wild {
  z-index: 2;
  background: #1a1d24;
  color: #ffcf4d;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  top: 2px;
  right: 2px;
  text-shadow: none;
}

/* Sounds + between-round shuffle (Nov 23, 2026). The mute toggle sits under
   the scoreboard; the shuffle is a decorative overlay on the felt that never takes a
   tap (transform/opacity only, Web Animations, ~1.5 s, skipped on reduced
   motion where only the sound plays). */
/* Under the points board (Nov 24, Dannel): its own short line, left-aligned. */
.board-top-row > .sound-toggle { order: 4; align-self: flex-start; margin: 2px 0 0; padding: 2px 10px; min-width: 36px; min-height: 26px; line-height: 1.3; font-size: .85em; }
.shuffle-fx { position: absolute; inset: 0; z-index: 25; pointer-events: none; }
.shuffle-card {
  position: absolute; width: 46px; height: 66px; border-radius: 6px;
  background: #f7f3e9 url("card-back.jpg") center/cover no-repeat;
  border: 1px solid #d8cfb8; box-shadow: 0 2px 5px rgba(0,0,0,.35);
  opacity: 0; will-change: transform, opacity;
}
@media (prefers-reduced-motion: reduce) { .shuffle-fx { display: none; } }

/* Crash rejoin (Nov 29, 2026): a dropped player's seat shows a small "Away"
   tag; "Away · bot playing" while the stand-in plays their turns. */
.away-tag { display: inline-block; font-size: 0.68em; line-height: 1.3; padding: 0 6px; border-radius: 999px; background: #f2a93b; color: #1b1b1b; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.away-tag.standin { background: #7c4dff; color: #fff; }
.seat .away-tag { display: block; width: max-content; margin: 2px auto 0; }

/* Nov 29, 2026: the waiting / spectator banner floats over the reserved
   action slot instead of taking a row of its own, so showing it never
   shrinks the felt or moves the hand. */
#action-slot { position: relative; }
#action-slot > #status-banner {
  position: absolute; inset: 0; z-index: 3; margin: 0;
  padding: 4px 10px; box-sizing: border-box; overflow: hidden;
  font-size: 0.85em; line-height: 1.25; gap: 4px 8px;
  justify-content: center; align-content: center;
  background-color: #1d2430; /* opaque over the empty slot */
}
#action-slot > #status-banner button { padding: 4px 10px; font-size: 0.9em; min-height: 32px; }
/* Seat Away tag hangs under the seat box, so the seat never grows. */
.seat .away-tag { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin: 2px 0 0; z-index: 2; }

/* "NAME is back" toast (Nov 29, 2026): floats on the felt, out of the flow. */
.back-toast {
  position: absolute; left: 50%; top: 26%; transform: translate(-50%, -6px);
  z-index: 6; pointer-events: none; opacity: 0;
  padding: 6px 14px; border-radius: 999px; white-space: nowrap; max-width: 90%;
  overflow: hidden; text-overflow: ellipsis;
  background: rgba(20, 130, 80, 0.95); color: #fff; font-weight: 700; font-size: 0.95em;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  transition: opacity .25s ease, transform .25s ease;
}
.back-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Live waiting room (Nov 29, 2026, Dannel) ----
   Seat cards, ready-up, quick reactions, the deck preview, the tip of the day
   and the share / joined toasts. Lobby only: nothing here touches #game. */
#room-info:not(.hidden) { display: flex; flex-direction: column; }
#room-info > * { order: 0; }
#room-info > #lobby-players { order: 1; }
#room-info > #room-waiting { order: 2; }
#room-info > #ready-row { order: 3; }
#room-info > #btn-host-start { order: 4; align-self: flex-start; }
#room-info > #reaction-row { order: 5; }
#room-info > #deck-preview { order: 6; }
#room-info > #room-deck-row { order: 7; }
#room-info > #voice-link-row { order: 8; }
#room-info > #tip-card { order: 9; }
#room-info .share-buttons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#room-info .share-buttons button { margin: 0; }
#btn-room-sound { margin-left: auto !important; }

ul.seat-cards { list-style: none; padding: 0; margin: 8px 0 4px; display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); columns: auto; }
.seat-card { position: relative; display: grid; grid-template-columns: auto 1fr; align-items: center;
  column-gap: 8px; padding: 7px 10px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(26,29,36,0.55); transition: border-color .25s, box-shadow .25s, background .25s; }
.seat-card.enter { animation: sc-in .35s ease-out; }
@keyframes sc-in { from { transform: translateY(6px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.seat-card .sc-dot { width: 10px; height: 10px; border-radius: 50%; background: #555b66; }
.seat-card .sc-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; min-width: 0; }
.seat-card .sc-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.seat-card .sc-tag { font-size: .72em; color: var(--dim); }
.seat-card .sc-tag.host { color: var(--accent); }
.seat-card .sc-level { font-size: .72em; font-weight: 700; padding: 0 6px; border-radius: 8px; background: rgba(124,77,255,.25); }
.seat-card .sc-xp { grid-column: 2; height: 4px; margin-top: 4px; border-radius: 2px; background: rgba(255,255,255,.12); overflow: hidden; }
.seat-card .sc-xp-fill { display: block; height: 100%; background: linear-gradient(90deg, #7c4dff, #b388ff); }
.seat-card.ready { border-color: #3ecf8e; background: rgba(62,207,142,.14); box-shadow: 0 0 0 2px rgba(62,207,142,.25), 0 0 14px rgba(62,207,142,.25); }
.seat-card.ready .sc-dot { background: #3ecf8e; box-shadow: 0 0 8px #3ecf8e; }
.seat-card.is-you .sc-name { color: var(--accent); }
.seat-card .sc-pop { position: absolute; left: 50%; top: -6px; transform: translate(-50%, -60%) scale(.6);
  padding: 3px 10px; border-radius: 14px; background: #fff; color: #1a1d24; font-weight: 700; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,.35); opacity: 0; pointer-events: none; z-index: 5; }
.seat-card .sc-pop.show { animation: sc-pop 2s ease-out forwards; }
@keyframes sc-pop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  12% { opacity: 1; transform: translate(-50%, -70%) scale(1.08); }
  20% { transform: translate(-50%, -65%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -75%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -100%) scale(.95); }
}

.ready-row { display: flex; align-items: center; gap: 10px; margin: 4px 0; }
.ready-row #btn-ready { margin: 0; min-width: 120px; }
#btn-ready.is-ready { background: #3ecf8e; border-color: #3ecf8e; color: #10261b; }

.reaction-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.reaction-row .reaction { margin: 0; padding: 6px 10px; border-radius: 18px; font-size: .9em; }
.reaction-row .reaction.emoji-only { padding: 6px 9px; }

.deck-preview { display: flex; gap: 8px; margin: 6px 0; height: 72px; perspective: 600px; }
.deck-preview:empty { display: none; }
.deck-preview .dp-card { width: 46px; height: 72px; }
.deck-preview .dp-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateY(0deg); }
.deck-preview.flip .dp-inner { animation: dp-flip .6s ease-out both; animation-delay: calc(var(--i) * 120ms); }
@keyframes dp-flip { from { transform: rotateY(180deg); } to { transform: rotateY(0deg); } }
.deck-preview .dp-back, .deck-preview .dp-front { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 6px; }
.deck-preview .dp-back { background: url('/card-back.jpg') center / cover; transform: rotateY(180deg); }
.deck-preview .dp-front.card { width: 100%; height: 100%; min-width: 0; margin: 0; padding: 0; font-size: 12px; overflow: hidden; }
.deck-preview .dp-front.card .rank { font-size: 1.4em; }
.deck-preview .dp-front.card .emblem { width: 22px; height: 22px; }
.deck-preview .dp-front .sg-face { width: 100%; height: 100%; object-fit: cover; }
@media (prefers-reduced-motion: reduce) { .deck-preview.flip .dp-inner, .seat-card.enter, .tip-card.turn { animation: none; } }

.tip-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; width: 100%;
  margin: 8px 0 0; padding: 10px 12px; border-radius: 12px; border: 1px dashed rgba(124,77,255,.6);
  background: rgba(124,77,255,.1); color: var(--ink); font-weight: 400; }
.tip-card.life { border-color: rgba(62,207,142,.6); background: rgba(62,207,142,.08); }
.tip-card .tip-head { font-size: .75em; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.tip-card .tip-text { font-size: .95em; }
.tip-card .tip-next { font-size: .72em; }
.tip-card.turn { animation: tip-turn .35s ease-out; }
@keyframes tip-turn { from { transform: rotateX(70deg); opacity: .3; } to { transform: none; opacity: 1; } }

.lobby-toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 80;
  transform: translate(-50%, 20px); padding: 9px 16px; border-radius: 20px; background: #fff; color: #1a1d24;
  font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.4); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center; }
.lobby-toast.show { opacity: 1; transform: translate(-50%, 0); }

ul#lobby-players.seat-cards { padding: 0; }
/* Phones: two seat cards a row, tighter spacing, a smaller deck preview. */
@media (max-width: 480px) {
  ul.seat-cards { grid-template-columns: 1fr 1fr; }
  .deck-preview { height: 58px; } .deck-preview .dp-card { width: 37px; height: 58px; }
  .seat-card { padding: 6px 8px; }
  #room-info .share-buttons button { padding: 6px 10px; }
}
/* Phone landscape: the old 3-column player list rule must not fight the grid. */
@media (orientation: landscape) and (max-height: 500px) {
  ul#lobby-players.seat-cards { columns: auto; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .deck-preview { height: 56px; } .deck-preview .dp-card { width: 36px; height: 56px; }
}

/* ---- Round table (Nov 29, 2026, Dannel: "a circle, not an oval") ----
   The #table box keeps its flex sizing (the layout lock above is unchanged);
   the felt is a circle drawn inside it, 100cqmin across, so it stays round
   whatever shape the box is. Seats are placed on that circle in cqmin units
   (renderTableSeats), and the meld area is kept inside it. */
#game > #table {
  background: none; box-shadow: none; border-radius: 0;
}
#game > #table::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 100cqmin; height: 100cqmin; transform: translate(-50%, -50%);
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 50% 42%, #2f6aa8 0%, #23558c 55%, #183d66 100%);
  box-shadow:
    inset 0 0 0 9px #6e4524, inset 0 0 0 12px #3f2713,
    inset 0 0 46px rgba(0,0,0,.5), 0 12px 28px rgba(0,0,0,.45);
}
#game > #table #felt-melds { left: calc(50% - 38cqmin); right: calc(50% - 38cqmin); }
#game > #table #me-seat { top: calc(50% + 50cqmin); }
#game > #table #table-voice { left: calc(50% - 46cqmin); bottom: auto; top: calc(50% + 34cqmin); }
/* Phones, portrait: the box was a tall oval; cap it at about its width so the
   circle fills it, and let the spare height sit evenly above and below. */
@media (max-width: 640px) {
  #game > #table { max-height: calc(100vw - 12px); margin-top: auto; margin-bottom: auto; }
}
/* Piles a little higher than on the oval, so the frames' bottom corners stay
   inside the circle (2-6 players, phone portrait and landscape). */
#game > #table #center { top: calc(50% + 11cqmin); }
/* Accounts (Nov 29, 2026): sign-in for XP on the landing screen. */
.account-bar { margin-top: 4px; }
.account-bar p { margin: 4px 0; }
.link-btn { background: none; border: none; padding: 4px 0; color: var(--accent); text-decoration: underline; font-weight: 600; cursor: pointer; }
.account-line { font-size: 0.95em; }
.xp-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; max-width: 260px; }
.xp-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.4s ease; }
.auth-box { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 14px 0; }
.auth-step { display: flex; flex-direction: column; gap: 10px; }
.auth-step h2 { margin: 0; font-size: 1.3em; }
.auth-step p { margin: 0; }
.auth-step input { font-size: 18px; padding: 10px 12px; }
#auth-code-input { letter-spacing: 0.35em; font-variant-numeric: tabular-nums; }
.auth-big-name { font-size: 1.8em; font-weight: 800; text-align: center; padding: 10px; border: 2px dashed var(--accent); border-radius: 10px; }
.auth-warning { color: #ffcf6b; font-weight: 600; }
.go-xp { font-weight: 700; color: var(--accent); margin: 6px 0; }
#auth-msg:empty { display: none; }
