:root {
  --felt: #1c6b3c;
  --felt-dark: #124a2a;
  --rail: #5a2d0c;
  --panel: #f7f3e8;
  --ink: #2b2620;
  --red: #c0392b;
  --gold: #d4a017;
  --ok: #2e7d32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at 50% 0%, #3a6b42, #17301d 70%);
  min-height: 100vh;
  color: var(--panel);
}

.hidden { display: none !important; }

/* ---------- barre du haut ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.35);
}
.topbar h1 { margin: 0; font-size: 1.4rem; letter-spacing: 1px; }

.btn-help {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  background: var(--gold);
  color: #000;
  font-weight: 800; font-size: 1.1rem;
  cursor: pointer;
}
.btn-help:hover { filter: brightness(1.1); }

.mini-help {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  font-weight: 800;
  font-size: 0.7rem;
  cursor: pointer;
  vertical-align: middle;
}

/* ---------- lobby ---------- */
#screen-lobby { padding: 24px 16px; max-width: 900px; margin: 0 auto; }

.lobby-home {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}
.card {
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.card h2 { margin-top: 0; }
.card label { display: block; margin: 12px 0; font-weight: 600; }
.card label button { margin-left: 6px; }
.card input, .card select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  font-size: 1rem;
  border: 1px solid #b8a67e;
  border-radius: 8px;
}

button.primary {
  width: 100%;
  padding: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: var(--ok);
  color: #fff;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.08); }
button.secondary {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #b8a67e;
  background: #eee;
  cursor: pointer;
}

.lobby-room .room-header { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.room-code {
  font-size: 1.6rem;
  letter-spacing: 6px;
  background: var(--gold);
  color: #000;
  padding: 2px 14px;
  border-radius: 8px;
}
.hint { color: #cfc4a8; font-size: 0.9rem; }
.lobby-room h3 { margin-top: 22px; }

.player-list { list-style: none; padding: 0; }
.player-list li {
  padding: 8px 12px;
  margin: 6px 0;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}
.player-list li .medal { margin-right: 8px; }

.room-actions { display: flex; gap: 12px; align-items: center; margin-top: 18px; }
.room-actions .primary { width: auto; padding: 10px 20px; }

/* ---------- table ---------- */
#screen-table { padding: 12px; }

.table-wrap { max-width: 980px; margin: 0 auto; }

.table-meta {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px 10px 0 0;
  flex-wrap: wrap;
}
.table-meta b { color: var(--gold); }

.table {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 40%, #2b8a4f 0%, var(--felt) 55%, var(--felt-dark) 100%);
  border: 14px solid var(--rail);
  border-radius: 220px / 140px;
  min-height: 460px;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.5);
}

.community {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 10px;
  padding: 8px;
}

.seats { position: absolute; inset: 0; }

.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 130px;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  border: 3px solid transparent;
}
.seat.acting { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 160, 23, 0.5), 0 4px 10px rgba(0,0,0,.35); }
.seat.folded { opacity: 0.45; }
.seat.eliminated { opacity: 0.25; filter: grayscale(1); }
.seat .sname { font-weight: 700; }
.seat .schips { font-size: 0.85rem; color: #555; }
.seat .stbet { font-size: 0.8rem; color: var(--ok); font-weight: 600; }
.seat .badges { display: flex; gap: 4px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
.badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 700;
  color: #fff;
}
.badge.dealer { background: #555; }
.badge.sb { background: #7f8c8d; }
.badge.bb { background: #b8860b; }
.badge.allin { background: var(--red); }
.badge.you { background: var(--ok); }
.badge.win { background: var(--gold); }
.badge.bot { background: #8e44ad; }

.infoline {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.55);
  border-radius: 20px;
  padding: 8px 18px;
  font-size: 0.95rem;
  white-space: nowrap;
}

.winner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid var(--gold);
  border-radius: 20px;
  padding: 6px 18px;
  font-weight: 800;
  color: var(--gold);
  max-width: 80%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* palmarès de fin de partie */
.palmares-wrap {
  margin: 14px auto 0;
  max-width: 640px;
}
.palmares {
  width: 100%;
  border-collapse: collapse;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  overflow: hidden;
  color: #fff;
}
.palmares th, .palmares td {
  border: 1px solid #b8a67e;
  padding: 6px 10px;
  text-align: center;
  font-size: 0.85rem;
}
.palmares th {
  background: var(--gold);
  color: #000;
}
.palmares td { background: rgba(0, 0, 0, 0.25); }
.table-sub { text-align: center; margin-top: 10px; }
.table-sub .primary { width: auto; }

/* ---------- cartes ---------- */
.cardo {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 74px;
  background: #fff;
  color: #000;
  border-radius: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35);
  border: 1px solid #ccc;
  animation: cardpop 0.25s ease-out;
}
@keyframes cardpop {
  from { transform: scale(0.85) translateY(6px); opacity: 0.4; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.cardo.red { color: var(--red); }
.cardo.back { background: repeating-linear-gradient(45deg, #2a4d8f, #2a4d8f 6px, #3a5da0 6px, #3a5da0 12px); color: transparent; }
.cardo small { font-size: 0.5rem; }

.layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 14px;
  margin-top: 14px;
}
.panel {
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.panel h3 { margin: 0 0 10px; }

.actions { display: flex; flex-direction: column; gap: 8px; }
.actions .act-row { display: flex; gap: 8px; align-items: center; }
.actions .act-row .act { flex: 1; }
.actions .act {
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  background: #e8e0ce;
}
.actions .act:hover { filter: brightness(0.95); }
.actions .act.danger { background: var(--red); color: #fff; }
.actions .act.primary2 { background: var(--ok); color: #fff; }
.actions .act.small { padding: 8px 12px; }

.raise-row { display: flex; gap: 8px; align-items: center; }
.raise-row .amount-lab { flex: 1; font-weight: 600; font-size: 0.85rem; }
.raise-row input {
  width: 100%;
  padding: 8px;
  font-size: 1rem;
  border: 1px solid #b8a67e;
  border-radius: 8px;
}

.log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.log li { padding: 3px 0; font-size: 0.9rem; border-bottom: 1px dotted #ddd; }

/* ---------- chat ---------- */
.chat-log { list-style: none; margin: 0 0 8px; padding: 0; max-height: 180px; overflow-y: auto; }
.chat-log li { padding: 3px 6px; font-size: 0.88rem; border-radius: 6px; }
.chat-log li.me { background: rgba(35, 134, 54, 0.12); }
.chat-log li.sys { color: #888; font-style: italic; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input {
  flex: 1;
  padding: 8px;
  font-size: 0.95rem;
  border: 1px solid #b8a67e;
  border-radius: 8px;
}

.btn.link { background: none; border: none; color: var(--ok); cursor: pointer; text-decoration: underline; padding: 0; }
.room-meta b { color: var(--gold); }

/* ---------- popover ---------- */
.popover {
  position: fixed;
  z-index: 60;
  max-width: 300px;
  background: #fffbe8;
  color: var(--ink);
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}
.popover b { color: #9a6a00; }

/* ---------- modale ---------- */
.modal {
  position: fixed;
  z-index: 70;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  width: min(680px, 92vw);
  max-height: 84vh;
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(0, 0, 0, 0.55);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #ddd;
}
.modal-head h2 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--ink);
}
.modal-tabs { display: flex; gap: 6px; padding: 10px 18px 0; }
.modal-tabs .tab {
  padding: 8px 14px;
  border: none;
  border-radius: 8px 8px 0 0;
  background: #e6dcc4;
  cursor: pointer;
  font-weight: 600;
}
.modal-tabs .tab.active { background: var(--ok); color: #fff; }
.modal-body { padding: 14px 18px 22px; overflow-y: auto; }
.modal-body h3 { color: var(--ok); margin-top: 18px; }
.modal-body ul { padding-left: 20px; }
.modal-body .term { font-weight: 800; }

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .table { border-radius: 120px / 70px; min-height: 380px; }
  .cardo { width: 42px; height: 60px; font-size: 0.95rem; }
}