:root {
  --felt: #0f5a40;
  --felt-deep: #073424;
  --felt-line: rgba(232, 214, 160, 0.28);
  --rail: #3a2216;
  --rail-dark: #1f120b;
  --room: #1a110c;
  --brass: #c8a255;
  --brass-soft: #e5cf92;
  --ivory: #f7f3e8;
  --ink: #16120f;
  --red: #b42318;
  --win: #7fd69b;
  --lose: #f19a8e;
  --muted: rgba(247, 243, 232, 0.62);
  --chip-5: #b3261e;
  --chip-10: #2459a8;
  --chip-25: #2f8f4e;
  --chip-100: #25201c;
  --chip-500: #6b3fa0;
  --radius-card: 7px;
  --card-w: clamp(46px, 5.2vw, 72px);
  --serif: 'Bodoni Moda', 'Didot', Georgia, serif;
  --sans: 'Instrument Sans', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at 50% 0%, #2b1b12 0%, var(--room) 60%);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
body.booting::after {
  content: 'Connexion…';
  position: fixed; inset: 0;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 1.4rem; color: var(--brass-soft);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2 { margin: 0; font-weight: 500; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass-soft); outline-offset: 2px; }

/* ---------- boutons ---------- */
.btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.6em 1.25em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, background-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-brass { background: var(--brass); color: var(--ink); }
.btn-brass:hover:not(:disabled) { background: var(--brass-soft); }
.btn-ghost { background: transparent; border-color: rgba(200, 162, 85, 0.55); color: var(--brass-soft); }
.btn-ghost:hover:not(:disabled) { background: rgba(200, 162, 85, 0.12); }
.btn-sm { padding: 0.35em 0.9em; font-size: 0.88rem; }
.icon-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(200, 162, 85, 0.4);
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.icon-btn[aria-pressed='true'] { opacity: 0.45; text-decoration: line-through; }
.badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px;
  background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 17px;
}

input {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(200, 162, 85, 0.35);
  border-radius: 10px;
  padding: 0.6em 0.9em;
  min-width: 0;
}
input::placeholder { color: rgba(247, 243, 232, 0.4); }
input:focus { border-color: var(--brass); outline: none; }

/* ---------- connexion ---------- */
#view-login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse 90% 70% at 50% 40%, var(--felt) 0%, var(--felt-deep) 75%, var(--room) 100%);
}
.login { width: min(560px, 100%); text-align: center; }
.arc-title { width: 100%; height: auto; margin-bottom: -24px; }
.arc-title text {
  font-family: var(--serif);
  font-size: 58px;
  font-weight: 700;
  fill: var(--brass-soft);
  letter-spacing: 1px;
}
.login-lead { font-size: 1.1rem; color: var(--ivory); max-width: 36ch; margin: 0 auto 28px; }
.login-form { text-align: left; max-width: 380px; margin: 0 auto; }
.login-form label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 6px; }
.login-form .row { display: flex; gap: 8px; }
.login-form input { flex: 1; font-size: 1.05rem; }
.form-error { min-height: 1.4em; color: var(--lose); font-size: 0.9rem; margin: 8px 0 0; }
.login-note { font-size: 0.85rem; color: var(--muted); margin-top: 28px; }

/* ---------- barre du haut ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(200, 162, 85, 0.2);
  background: linear-gradient(var(--rail), var(--rail-dark));
  min-height: 56px;
}
.brand { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; color: var(--brass-soft); }
.me { display: flex; align-items: center; gap: 10px; }
.me-name { color: var(--muted); }
.stack {
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.stack::before {
  content: '';
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--brass);
  box-shadow: inset 0 0 0 3px var(--rail-dark), inset 0 0 0 4px var(--brass-soft);
}
.stack.bump { animation: bump 0.5s; }
@keyframes bump { 40% { color: var(--brass-soft); transform: scale(1.12); } }

/* ---------- salon ---------- */
.lobby {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  grid-template-areas: 'tables board' 'rules board';
  gap: 20px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.tables-panel { grid-area: tables; }
.board-panel { grid-area: board; }
.rules-panel { grid-area: rules; }
.panel {
  background: linear-gradient(160deg, var(--felt) 0%, var(--felt-deep) 100%);
  border: 6px solid var(--rail);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 0 0 1px var(--rail-dark), 0 18px 40px rgba(0, 0, 0, 0.45);
}
.panel h2 { font-family: var(--serif); font-size: 1.5rem; color: var(--brass-soft); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.hint, .online { font-size: 0.85rem; color: var(--muted); }

.table-list { list-style: none; margin: 0 0 16px; padding: 0; }
.table-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--felt-line);
}
.table-row:first-child { border-top: 1px solid var(--felt-line); }
.table-row .t-name { font-weight: 600; font-size: 1.05rem; }
.table-row .t-meta { grid-column: 1; font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-row .btn { grid-row: 1 / span 2; grid-column: 2; }
.seat-dots { display: inline-flex; gap: 4px; }
.seat-dots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--brass); }
.seat-dots i.on { background: var(--brass); }
.live { color: var(--brass-soft); }
.create-form { display: flex; gap: 8px; margin-top: 10px; }
.create-form input { flex: 1; }

.leaderboard { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.leaderboard li {
  counter-increment: rank;
  display: grid;
  grid-template-columns: 2ch 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--felt-line);
}
.leaderboard li::before { content: counter(rank); font-family: var(--serif); color: var(--brass); text-align: right; }
.leaderboard li:nth-child(-n + 3)::before { font-weight: 700; color: var(--brass-soft); }
.leaderboard .lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard .lb-sub { display: block; font-size: 0.78rem; color: var(--muted); }
.leaderboard .lb-net { font-variant-numeric: tabular-nums; font-weight: 700; }
.leaderboard .me-row .lb-name { color: var(--brass-soft); font-weight: 700; }
.pos { color: var(--win); }
.neg { color: var(--lose); }
.empty { color: var(--muted); padding: 12px 0; }

.rules { margin: 12px 0 0; padding-left: 1.1em; color: var(--ivory); }
.rules li { margin: 4px 0; }
.rules li::marker { color: var(--brass); content: '♠  '; }

/* ---------- table ---------- */
.view-table { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.table-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
#table-name { font-family: var(--serif); font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-chip {
  border: 1px dashed rgba(200, 162, 85, 0.6);
  background: none;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}
.code-chip b { color: var(--brass-soft); letter-spacing: 1px; }

.table-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: 'felt chat' 'controls chat';
}
.felt-wrap { grid-area: felt; padding: 16px; display: grid; place-items: center; min-height: 0; }
.felt {
  position: relative;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  max-height: 720px;
  min-height: 420px;
  border-radius: 48% 48% 26px 26px / 22% 22% 26px 26px;
  background:
    radial-gradient(ellipse 70% 60% at 50% 30%, rgba(255, 255, 255, 0.07), transparent 70%),
    radial-gradient(ellipse at 50% 100%, var(--felt) 0%, var(--felt-deep) 100%);
  border: 14px solid var(--rail);
  box-shadow:
    inset 0 0 0 2px var(--brass),
    inset 0 8px 40px rgba(0, 0, 0, 0.5),
    0 0 0 2px var(--rail-dark),
    0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.felt-print { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.felt-print text { fill: rgba(232, 214, 160, 0.42); font-family: var(--serif); }
.print-big { font-size: 38px; font-weight: 700; letter-spacing: 3px; }
.print-small { font-size: 17px; font-style: italic; letter-spacing: 1px; }

.shoe {
  position: absolute;
  top: 44px; right: 10%;
  width: 70px; height: 48px;
  border-radius: 6px 6px 10px 10px;
  background: linear-gradient(#2a2a2a, #0d0d0d);
  transform: perspective(200px) rotateX(20deg);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}
.shoe span {
  position: absolute; left: 8px; right: 8px; top: 6px; height: 26px;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, var(--red) 0 4px, #8e1a12 4px 8px);
  border: 2px solid var(--ivory);
}

.dealer {
  position: absolute;
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.dealer .who { font-family: var(--serif); font-style: italic; color: var(--brass-soft); font-size: 0.95rem; }

.status {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  width: 80%;
}
.status .msg { font-family: var(--serif); font-size: clamp(1.1rem, 2.2vw, 1.6rem); text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.status .timer {
  width: 180px; height: 4px;
  margin: 8px auto 0;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 2px;
  overflow: hidden;
}
.status .timer i { display: block; height: 100%; background: var(--brass); transform-origin: left; }

/* sièges disposés en arc */
.seats { position: absolute; inset: 0; pointer-events: none; }
.seat {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -100%);
  width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}
.seat-plate {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 118px;
  padding: 5px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(232, 214, 160, 0.25);
  font-size: 0.85rem;
  line-height: 1.25;
}
.seat-plate .name { font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-plate .bal { color: var(--muted); font-variant-numeric: tabular-nums; }
.seat.is-me .seat-plate { border-color: var(--brass); background: rgba(200, 162, 85, 0.16); }
.seat.is-turn .seat-plate { box-shadow: 0 0 0 2px var(--brass-soft), 0 0 22px rgba(229, 207, 146, 0.55); }
.seat.away .seat-plate { opacity: 0.55; }
.seat.away .name::after { content: ' (absent)'; font-weight: 400; color: var(--muted); }
.seat-empty {
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 2px dashed rgba(232, 214, 160, 0.35);
  background: none;
  color: rgba(232, 214, 160, 0.7);
  font-size: 0.85rem;
  cursor: pointer;
}
.seat-empty:hover:not(:disabled) { border-color: var(--brass-soft); color: var(--brass-soft); background: rgba(200, 162, 85, 0.08); }
.seat-empty:disabled { cursor: default; opacity: 0.5; }

.hands { display: flex; gap: 10px; align-items: flex-end; justify-content: center; }
.hand { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.hand.active .cards { filter: drop-shadow(0 0 10px rgba(229, 207, 146, 0.8)); }
.hand.done-lose .cards { opacity: 0.55; }
.hand-info { display: flex; gap: 6px; align-items: center; font-size: 0.8rem; }
.total {
  font-weight: 700;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}
.total.bust { background: var(--red); }
.total.bj { background: var(--brass); color: var(--ink); }
.result {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-6deg);
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  animation: stamp 0.35s cubic-bezier(0.2, 1.6, 0.4, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  z-index: 5;
}
.result.win, .result.blackjack { background: var(--ivory); color: #1d6b39; border: 2px solid #1d6b39; }
.result.blackjack { background: var(--brass-soft); color: var(--ink); border-color: var(--ink); }
.result.lose { background: var(--ivory); color: var(--red); border: 2px solid var(--red); }
.result.push { background: var(--ivory); color: #444; border: 2px solid #444; }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-6deg) scale(1.8); opacity: 0; } }

/* jetons */
.bet-spot { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.chip-stack { display: inline-grid; }
.chip-stack .chip { grid-area: 1 / 1; }
.chip {
  --c: var(--chip-10);
  width: 30px; height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--c) 0 42%, transparent 43%),
    repeating-conic-gradient(var(--c) 0 30deg, var(--ivory) 30deg 45deg);
  border: 2px solid var(--c);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700; color: var(--ivory);
}
.chip[data-v='5'] { --c: var(--chip-5); }
.chip[data-v='25'] { --c: var(--chip-25); }
.chip[data-v='100'] { --c: var(--chip-100); }
.chip[data-v='500'] { --c: var(--chip-500); }
.bet-amount { font-weight: 700; font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }

/* cartes */
.cards { display: flex; min-height: calc(var(--card-w) * 1.4); }
.card {
  width: var(--card-w);
  aspect-ratio: 5 / 7;
  border-radius: var(--radius-card);
  background: var(--ivory);
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  position: relative;
  flex-shrink: 0;
  font-family: var(--serif);
  user-select: none;
}
.cards .card + .card { margin-left: calc(var(--card-w) * -0.62); }
.card.red { color: var(--red); }
.card .idx {
  position: absolute;
  top: 4%; left: 7%;
  display: flex; flex-direction: column; align-items: center;
  font-size: calc(var(--card-w) * 0.3);
  font-weight: 700;
  line-height: 0.95;
}
.card .idx small { font-size: 0.8em; font-family: var(--sans); }
.card .idx.bottom { top: auto; left: auto; bottom: 4%; right: 7%; transform: rotate(180deg); }
.card .pip {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: calc(var(--card-w) * 0.52);
  font-family: var(--sans);
}
.card .pip.face {
  font-family: var(--serif);
  font-style: italic;
  font-size: calc(var(--card-w) * 0.5);
  inset: 20% 17%;
  border: 1px solid currentColor;
  border-radius: 3px;
  opacity: 0.9;
}
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 7px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 0 3px, transparent 3px 7px),
    var(--red);
  border: 3px solid var(--ivory);
}
.card.enter { animation: deal 0.38s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
@keyframes deal {
  from { transform: translate(var(--from-x, 180px), var(--from-y, -260px)) rotate(-25deg) scale(0.7); opacity: 0.2; }
}
.card.flip { animation: flip 0.45s ease-out both; }
@keyframes flip { from { transform: rotateY(90deg); } }

/* barre de contrôle */
.controls {
  grid-area: controls;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(var(--rail), var(--rail-dark));
  border-top: 1px solid rgba(200, 162, 85, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 76px;
}
.controls .note { color: var(--muted); }
.chip-btn {
  width: 52px; height: 52px;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.12s;
}
.chip-btn:hover:not(:disabled) { transform: translateY(-3px); }
.chip-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.act-btn { min-width: 108px; font-size: 1rem; }
.act-btn kbd {
  font-family: var(--sans);
  font-size: 0.72rem;
  opacity: 0.6;
  margin-left: 6px;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
}
.sep { width: 1px; align-self: stretch; background: rgba(200, 162, 85, 0.25); margin: 0 4px; }

/* chat */
.chat {
  grid-area: chat;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid rgba(200, 162, 85, 0.2);
  background: #20150f;
}
.chat-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 14px; border-bottom: 1px solid rgba(200, 162, 85, 0.15); }
.chat-head h2 { font-family: var(--serif); font-size: 1.1rem; color: var(--brass-soft); }
.chat-close { display: none; margin-left: auto; }
.chat-log { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.chat-log .sys { color: var(--muted); font-style: italic; font-size: 0.82rem; }
.chat-log b { color: var(--brass-soft); font-weight: 600; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgba(200, 162, 85, 0.15); }
.chat-form input { flex: 1; }

/* toasts & connexion */
.toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--ivory); color: var(--ink); border-left: 4px solid var(--red); padding: 10px 14px; border-radius: 8px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4); animation: toast 0.2s ease-out; }
.toast.ok { border-left-color: #1d6b39; }
@keyframes toast { from { transform: translateY(-8px); opacity: 0; } }
.conn { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--red); color: #fff; padding: 8px 16px; border-radius: 999px; z-index: 60; font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .table-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'felt' 'controls'; }
  .chat {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(340px, 90vw);
    z-index: 40;
    transform: translateX(100%);
    transition: transform 0.2s ease-out;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  }
  .chat.open { transform: none; }
  .chat-close { display: inline-block; }
}
@media (min-width: 1101px) { #chat-toggle { display: none; } }

@media (max-width: 820px) {
  .lobby { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'tables' 'board' 'rules'; }
  :root { --card-w: 44px; }
  .felt-wrap { padding: 8px; place-items: stretch; overflow-y: auto; }
  .felt {
    height: auto;
    max-height: none;
    min-height: 0;
    overflow: visible;
    border-width: 8px;
    border-radius: 40% 40% 18px 18px / 90px 90px 18px 18px;
    padding: 20px 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }
  .felt-print, .shoe { display: none; }
  .dealer, .status { position: static; transform: none; }
  .status { width: auto; min-height: 2.6em; }
  .seats {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 6px;
    width: 100%;
  }
  .seat { position: static; transform: none; width: auto; }
  .seat.is-me { order: -1; grid-column: 1 / -1; }
  .seat.is-me { --card-w: 56px; }
  .seat-empty { width: 64px; height: 64px; }
  .act-btn { min-width: 0; flex: 1; padding: 0.7em 0.3em; font-size: 0.95rem; }
  .controls { flex-wrap: nowrap; gap: 6px; }
  .controls:has(.chip-btn) { flex-wrap: wrap; }
  .seats.seated .seat:has(.seat-empty) { display: none; }
  .act-btn kbd { display: none; }
  .chip-btn { width: 46px; height: 46px; }
  .topbar .me-name { display: none; }
  .me { gap: 6px; }
  .code-chip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* contrôles de mise */
.spots { display: inline-flex; border: 1px solid rgba(200, 162, 85, 0.4); border-radius: 12px; overflow: hidden; }
.spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  padding: 4px 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  line-height: 1.2;
}
.spot + .spot { border-left: 1px solid rgba(200, 162, 85, 0.3); }
.spot span { font-size: 0.75rem; color: var(--muted); }
.spot b { font-variant-numeric: tabular-nums; }
.spot.on { background: rgba(200, 162, 85, 0.22); }
.spot.on span { color: var(--brass-soft); }
.spot:disabled { opacity: 0.4; cursor: not-allowed; }
.chip-row { display: inline-flex; gap: 8px; align-items: center; }

@media (max-width: 820px) {
  .felt.mode-3d { min-height: 0; height: 100%; }
  .felt-wrap:has(.mode-3d) { overflow: hidden; }
  .controls:has(.spots) { flex-wrap: wrap; row-gap: 8px; }
  .spots { width: 100%; }
  .spot { flex: 1; min-width: 0; }
  .chip-row { gap: 4px; }
  .plate3d { min-width: 0; padding: 3px 8px; font-size: 0.75rem; }
  .plate3d .n { max-width: 80px; }
  .tag { font-size: 0.78rem; padding: 1px 7px; }
  .stamp { font-size: 0.8rem; padding: 2px 8px; }
  .sidewin { font-size: 0.72rem; }
}

/* ================= mode 3D : plein écran, interface en verre ================= */
.view-table.mode-3d { position: relative; background: #0c0705; }
.view-table.mode-3d .topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  background: linear-gradient(rgba(8, 5, 3, 0.75), rgba(8, 5, 3, 0));
  border-bottom: 0;
  padding: 12px 18px 28px;
  pointer-events: none;
}
.view-table.mode-3d .topbar > * { pointer-events: auto; }
.view-table.mode-3d .table-layout { display: block; position: relative; height: 100%; }
.view-table.mode-3d .felt-wrap { position: absolute; inset: 0; padding: 0; }
.felt.mode-3d {
  position: relative; width: 100%; height: 100%;
  max-width: none; max-height: none; min-height: 0;
  border: 0; border-radius: 0; box-shadow: none; background: #0c0705; padding: 0;
  display: block; overflow: hidden;
}
.felt.mode-3d .felt-print, .felt.mode-3d .shoe, .felt.mode-3d .dealer, .felt.mode-3d .seats { display: none; }
.gl { position: absolute; inset: 0; display: block; touch-action: manipulation; }
.overlay3d { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.anchor { position: absolute; left: 0; top: 0; will-change: transform; }
.anchor button { pointer-events: auto; }

.glass {
  background: rgba(16, 11, 8, 0.52);
  border: 1px solid rgba(255, 236, 200, 0.12);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

/* statut + minuteur */
.felt.mode-3d .status {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  z-index: 3; width: auto; max-width: 90%;
  display: flex; align-items: center; gap: 12px;
  padding: 6px 18px 6px 8px;
  border-radius: 999px;
  background: rgba(16, 11, 8, 0.5);
  border: 1px solid rgba(255, 236, 200, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.felt.mode-3d .status:has(.msg:empty) { display: none; }
.felt.mode-3d .status .msg { font-size: 1.05rem; text-shadow: none; white-space: nowrap; font-family: var(--serif); letter-spacing: 0.01em; }
.felt.mode-3d .status:not(:has(.ring)) { padding-left: 18px; }
.ring { position: relative; width: 40px; height: 40px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke: rgba(255, 236, 200, 0.15); stroke-width: 3; }
.ring .arc { stroke: var(--brass-soft); stroke-linecap: round; stroke-dasharray: 119.4; transition: stroke 0.3s; }
.ring.late .arc { stroke: #f08a7a; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 0.85rem; font-variant-numeric: tabular-nums; }

/* solde */
.view-table.mode-3d .hud-bank {
  position: absolute; left: 18px; bottom: 18px; z-index: 4;
  display: flex; gap: 18px;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(16, 11, 8, 0.52);
  border: 1px solid rgba(255, 236, 200, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.hud-bank:empty { display: none; }
.view-table:not(.mode-3d) .hud-bank { display: none; }
.hud-bank div { display: flex; flex-direction: column; line-height: 1.15; }
.hud-bank span { font-size: 0.72rem; color: var(--muted); }
.hud-bank b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.hud-bank div + div b { color: var(--brass-soft); }

/* dock du bas */
.view-table.mode-3d .controls {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 4;
  background: none; border: 0; padding: 0; min-height: 0;
  flex-direction: column; gap: 8px;
}
.view-table.mode-3d .controls .hint {
  margin: 0; padding: 4px 12px; border-radius: 999px;
  font-size: 0.82rem; color: rgba(247, 243, 232, 0.8);
  background: rgba(16, 11, 8, 0.45);
  text-align: center;
}
.dock {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  border-radius: 22px;
  background: rgba(16, 11, 8, 0.52);
  border: 1px solid rgba(255, 236, 200, 0.12);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.dock .hint.solo { background: none; padding: 0 6px; }
.chips { display: flex; gap: 8px; align-items: center; }
.chip3d {
  width: 54px; height: 54px; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.2, 1.4, 0.4, 1), filter 0.15s;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.55));
}
.chip3d img { width: 100%; height: 100%; display: block; border-radius: 50%; }
.chip3d:hover:not(:disabled) { transform: translateY(-3px); }
.chip3d.on { transform: translateY(-8px) scale(1.08); filter: drop-shadow(0 0 10px rgba(255, 220, 140, 0.75)) drop-shadow(0 6px 8px rgba(0, 0, 0, 0.6)); }
.chip3d:disabled { opacity: 0.3; cursor: not-allowed; }
.rbtn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--ivory);
}
.rbtn .ic {
  display: grid; place-items: center;
  width: 58px; height: 58px; border-radius: 50%;
  background: rgba(255, 245, 225, 0.08);
  border: 1.5px solid rgba(255, 236, 200, 0.35);
  transition: background 0.15s, transform 0.1s;
}
.rbtn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rbtn .lb { font-size: 0.78rem; color: rgba(247, 243, 232, 0.85); white-space: nowrap; }
.rbtn kbd { font-family: var(--sans); font-size: 0.66rem; opacity: 0.55; border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; }
.rbtn:hover:not(:disabled) .ic { background: rgba(255, 245, 225, 0.18); }
.rbtn:active:not(:disabled) .ic { transform: scale(0.94); }
.rbtn:disabled { opacity: 0.3; cursor: not-allowed; }
.rbtn.small .ic { width: 42px; height: 42px; }
.rbtn.small svg { width: 18px; height: 18px; }
.rbtn.act .ic { width: 66px; height: 66px; }
.rbtn.hit .ic { background: #1f7a4d; border-color: #6fd39d; }
.rbtn.stand .ic { background: #9b2b25; border-color: #f39a8f; }
.rbtn.double .ic, .rbtn.split .ic { background: rgba(201, 164, 90, 0.2); border-color: var(--brass-soft); color: var(--brass-soft); }
.rbtn.hit:hover:not(:disabled) .ic { background: #26925c; }
.rbtn.stand:hover:not(:disabled) .ic { background: #b5332c; }

/* étiquettes projetées */
.score {
  display: inline-grid; place-items: center;
  min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: 999px;
  background: rgba(12, 8, 6, 0.8);
  border: 1.5px solid rgba(255, 236, 200, 0.55);
  font-weight: 700; font-size: 0.92rem; font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}
.score.bust { background: #9b2b25; border-color: #f39a8f; }
.score.bj { background: linear-gradient(#f3dca0, #c9a45a); color: #1a120a; border-color: #fff3d0; }
.seat-tag {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 12px 5px; border-radius: 12px;
  background: rgba(16, 11, 8, 0.6);
  border: 1px solid rgba(255, 236, 200, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  line-height: 1.2; white-space: nowrap;
}
.seat-tag b { font-weight: 600; font-size: 0.85rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.seat-tag span { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.seat-tag i { font-style: normal; font-size: 0.68rem; color: var(--brass-soft); }
.seat-tag.me { border-color: rgba(229, 207, 146, 0.7); }
.seat-tag.me b { color: var(--brass-soft); }
.seat-tag.turn { box-shadow: 0 0 0 2px var(--brass-soft), 0 0 22px rgba(229, 207, 146, 0.55); }
.seat-tag.away { opacity: 0.5; }
.result-pill, .side-pill {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-weight: 600; font-size: 0.85rem; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  animation: pop 0.35s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.result-pill em, .side-pill em { font-style: normal; font-variant-numeric: tabular-nums; }
.result-pill.win { background: #1f7a4d; }
.result-pill.blackjack { background: linear-gradient(#f3dca0, #c9a45a); color: #1a120a; }
.result-pill.lose { background: rgba(60, 20, 18, 0.85); color: #f5b3aa; }
.result-pill.push { background: rgba(40, 36, 32, 0.85); }
.side-pill { background: linear-gradient(#f3dca0, #c9a45a); color: #1a120a; font-size: 0.78rem; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.sit3d {
  padding: 7px 14px; border-radius: 999px;
  background: rgba(16, 11, 8, 0.55);
  border: 1px solid rgba(255, 236, 200, 0.4);
  color: var(--ivory); font-weight: 600; font-size: 0.85rem; cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.sit3d:hover { background: rgba(201, 164, 90, 0.85); color: #1a120a; }

/* chat en verre, en bas à droite */
.view-table.mode-3d .chat {
  position: absolute; right: 18px; top: 70px; bottom: auto; left: auto; z-index: 4;
  width: 300px; height: 240px;
  transform: none;
  border: 1px solid rgba(255, 236, 200, 0.12);
  border-radius: 16px;
  background: rgba(16, 11, 8, 0.5);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: none;
  overflow: hidden;
}
.view-table.mode-3d .chat.closed { display: none; }
.view-table.mode-3d .chat-head { padding: 8px 12px; }
.view-table.mode-3d .chat-log { font-size: 0.82rem; padding: 8px 12px; }
.view-table.mode-3d .chat-form { padding: 8px; }
.view-table.mode-3d .chat-close { display: inline-block; }
.view-table.mode-3d #chat-toggle { display: inline-block; }

.credits { margin: 14px 0 0; font-size: 0.75rem; color: var(--muted); }

@media (max-width: 820px) {
  .view-table.mode-3d .topbar { padding: 8px 10px 20px; }
  .felt.mode-3d .status { top: 54px; padding: 4px 12px 4px 6px; }
  .felt.mode-3d .status .msg { font-size: 0.9rem; }
  .ring { width: 32px; height: 32px; }
  .view-table.mode-3d .hud-bank { left: 50%; transform: translateX(-50%); bottom: auto; top: 96px; padding: 6px 12px; gap: 14px; }
  .hud-bank b { font-size: 0.95rem; }
  .view-table.mode-3d .controls { bottom: 10px; width: calc(100% - 16px); }
  .dock { gap: 8px; padding: 8px 10px; justify-content: center; flex-wrap: wrap; }
  .chips { gap: 4px; }
  .chip3d { width: 44px; height: 44px; }
  .rbtn.act .ic { width: 58px; height: 58px; }
  .rbtn.small .ic { width: 36px; height: 36px; }
  .rbtn .lb { font-size: 0.7rem; }
  .rbtn kbd { display: none; }
  .view-table.mode-3d .controls .hint { font-size: 0.74rem; }
  .view-table.mode-3d .chat { left: 8px; right: 8px; width: auto; bottom: 150px; height: 240px; }
  .seat-tag { padding: 2px 8px; }
  .seat-tag b { font-size: 0.72rem; max-width: 80px; }
  .seat-tag span { font-size: 0.66rem; }
  .score { min-width: 28px; height: 28px; font-size: 0.8rem; }
  .result-pill, .side-pill { font-size: 0.72rem; padding: 3px 9px; }
}

.view-table.mode-3d #table-balance { display: none; }

/* ================= salon et connexion : même langage que la table ================= */
body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(201, 164, 90, 0.18), transparent 70%),
    radial-gradient(ellipse 70% 60% at 50% 110%, rgba(15, 91, 65, 0.35), transparent 70%),
    #0c0705;
}
#view-lobby .topbar { background: transparent; border-bottom: 1px solid rgba(255, 236, 200, 0.08); }
.panel {
  background: rgba(22, 15, 11, 0.6);
  border: 1px solid rgba(255, 236, 200, 0.1);
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.panel h2 { color: var(--ivory); }
.table-row, .leaderboard li { border-color: rgba(255, 236, 200, 0.08); }
.table-row:first-child { border-top-color: rgba(255, 236, 200, 0.08); }
.seat-dots i { border-color: rgba(229, 207, 146, 0.6); }
input { background: rgba(255, 245, 225, 0.05); border-color: rgba(255, 236, 200, 0.18); }
#view-login {
  background:
    radial-gradient(ellipse 60% 45% at 50% 42%, rgba(15, 91, 65, 0.55), transparent 75%),
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(201, 164, 90, 0.16), transparent 70%),
    #0c0705;
}
.rules li::marker { color: var(--brass-soft); }

.side-pill.dim { background: rgba(40, 30, 24, 0.85); color: var(--muted); }
.view-table.mode-3d .dock .btn { padding: 0.75em 1.3em; }

.chip-stack .chip:nth-child(2) { transform: translateY(-3px); }
.chip-stack .chip:nth-child(3) { transform: translateY(-6px); }
.chip-stack .chip:nth-child(4) { transform: translateY(-9px); }
.chip-stack .chip:nth-child(5) { transform: translateY(-12px); }
.chip-stack .chip:nth-child(6) { transform: translateY(-15px); }
