/* ============================================================ base */
:root {
  --bg: #0b0f14;
  --bg-2: #121821;
  --panel: #161d28;
  --panel-2: #1c2532;
  --line: #26313f;
  --text: #e8eef6;
  --muted: #8a97a8;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --gold: #f2c14e;
  --felt-1: #0f5132;
  --felt-2: #0a3a24;
  --red: #e0473f;
  --green: #2ecc71;
  --radius: 14px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
input { font: inherit; }

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* ============================================================ boutons */
.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 16px;
  transition: .15s;
}
.btn:hover:not(:disabled) { background: #243041; border-color: #33415480; transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(79, 140, 255, .28);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.big { width: 100%; padding: 14px; font-size: 16px; }
.btn.tiny { padding: 6px 10px; font-size: 13px; }

.btn.danger { background: #3a1d22; border-color: #5a2b33; color: #ffb3b3; }
.btn.gold { background: linear-gradient(135deg, #d9a521, #f2c14e); color: #241a00; border: none; font-weight: 700; }

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 12px;
  transition: .15s;
}
.ghost:hover { color: var(--text); border-color: #3a4759; }
.ghost.tiny { padding: 3px 8px; font-size: 12px; }

/* ============================================================ accueil */
#screen-home {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(79, 140, 255, .16), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(124, 92, 255, .16), transparent 55%),
    var(--bg);
}

.home { width: min(1040px, 100%); }

.home-head { text-align: center; margin-bottom: 40px; }
.logo {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 54px; height: 54px;
  margin-right: 10px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 30px;
  box-shadow: 0 10px 30px rgba(79, 140, 255, .35);
}
.tagline { color: var(--muted); margin-top: 12px; font-size: 17px; }

.games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}

.game-card {
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  transition: .18s;
  position: relative;
  overflow: hidden;
}
.game-card:hover { transform: translateY(-4px); border-color: #33415a; box-shadow: var(--shadow); }
.game-card.featured {
  grid-column: span 2;
  background:
    linear-gradient(135deg, rgba(79, 140, 255, .18), rgba(124, 92, 255, .12)),
    var(--panel);
  border-color: #2f4270;
}
.game-card.locked { opacity: .55; cursor: default; }
.game-card.locked:hover { transform: none; box-shadow: none; }

.game-art {
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: linear-gradient(180deg, #0d2a1d, #071711);
  border: 1px solid #123526;
  position: relative;
}
.game-art.simple { font-size: 46px; background: var(--panel-2); border-color: var(--line); }

.game-meta h2 { margin: 0 0 6px; font-size: 21px; }
.game-meta p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.badge.muted { background: #232c3a; color: var(--muted); }

/* cartes miniatures accueil */
.pc {
  width: 62px; height: 86px;
  background: #fff; color: #111;
  border-radius: 8px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .4);
  transform: rotate(-8deg);
}
.pc span { font-size: 22px; }
.pc.c2 { transform: rotate(8deg) translateY(6px); }
.pc.red { color: var(--red); }

/* ============================================================ login */
#screen-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: radial-gradient(900px 500px at 50% -20%, rgba(79, 140, 255, .14), transparent 60%), var(--bg);
}
.login { width: min(420px, 100%); position: relative; }
.login .back { position: absolute; top: -46px; left: 0; }

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.login-art { display: flex; justify-content: center; gap: 10px; margin-bottom: 14px; }
.login-card h1 { text-align: center; margin: 0 0 6px; font-size: 28px; }
.sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .join-row input, #chat-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  outline: none;
  transition: .15s;
}
.field input:focus, .join-row input:focus, #chat-input:focus { border-color: var(--accent); }

.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: 1px;
  margin: 20px 0 14px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; text-align: center; }
.join-row .btn { flex-shrink: 0; padding: 12px 22px; }

.error { color: #ff8b8b; font-size: 13px; min-height: 18px; margin: 12px 0 0; text-align: center; }
.hint { color: var(--muted); font-size: 12px; text-align: center; margin: 8px 0 0; }

/* ============================================================ table */
#screen-table {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.room-pill {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px 5px 14px;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.room-pill code {
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 15px;
}
.top-right { margin-left: auto; color: var(--muted); font-size: 14px; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 16px;
  align-items: start;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------- tapis */
.felt-col { display: flex; flex-direction: column; gap: 12px; }

.felt {
  position: relative;
  min-height: 520px;
  border-radius: 22px;
  padding: 18px;
  background:
    radial-gradient(ellipse at 50% 45%, var(--felt-1), var(--felt-2) 75%);
  border: 8px solid #2b1d12;
  box-shadow: inset 0 0 70px rgba(0, 0, 0, .55), var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  overflow: hidden;
}

.opponents {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  min-height: 108px;
}

.seat {
  background: rgba(0, 0, 0, .38);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 8px 10px;
  min-width: 132px;
  text-align: center;
  transition: .2s;
  position: relative;
}
.seat.turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 193, 78, .22), 0 0 22px rgba(242, 193, 78, .35);
  background: rgba(0, 0, 0, .55);
}
.seat.folded { opacity: .38; filter: grayscale(.7); }
.seat.off { opacity: .3; }

.seat .sname {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seat .schips { font-size: 13px; color: var(--gold); font-weight: 600; }
.seat .sinfo { font-size: 11px; color: #9fe6c0; min-height: 14px; }
.seat .sbet {
  position: absolute;
  top: -10px;
  right: -8px;
  background: var(--gold);
  color: #241a00;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 2px 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .4);
}
.seat .button-chip {
  position: absolute;
  top: -10px;
  left: -8px;
  background: #fff;
  color: #111;
  font-size: 11px;
  font-weight: 800;
  border-radius: 999px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .4);
}
.mini-cards { display: flex; gap: 4px; justify-content: center; margin-top: 6px; }

/* ---------------------------------------------------------- board */
.center { text-align: center; }

.pot-badge {
  display: inline-block;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .12);
  color: var(--gold);
  font-weight: 800;
  padding: 6px 18px;
  border-radius: 999px;
  margin-bottom: 12px;
  letter-spacing: .5px;
}

.board {
  display: flex;
  gap: 8px;
  justify-content: center;
  min-height: 96px;
  align-items: center;
}
.board .placeholder {
  color: rgba(255, 255, 255, .22);
  font-size: 14px;
  letter-spacing: 2px;
}

.street {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .5);
}

/* ---------------------------------------------------------- cartes */
.card {
  width: 62px;
  height: 88px;
  background: #fdfdfd;
  color: #101418;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .45);
  border: 1px solid rgba(0, 0, 0, .12);
  animation: deal .28s ease-out both;
}
.card span { font-size: 20px; margin-top: 4px; }
.card.red { color: var(--red); }
.card.sm { width: 42px; height: 59px; font-size: 17px; }
.card.sm span { font-size: 14px; }
.card.back {
  background:
    repeating-linear-gradient(45deg, #1e3a8a 0 6px, #172554 6px 12px);
  border: 3px solid #f5f5f5;
}
.card.back.sm { border-width: 2px; }
.card.empty { visibility: hidden; }

@keyframes deal {
  from { opacity: 0; transform: translateY(-14px) scale(.9); }
  to { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------- héros */
.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.hero .hero-cards { display: flex; gap: 8px; }
.hero .hero-info {
  background: rgba(0, 0, 0, .45);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 8px 16px;
  text-align: center;
  min-width: 170px;
}
.hero .hero-info.turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 193, 78, .2);
}
.hero .hero-info .sname { font-weight: 800; font-size: 15px; }
.hero .hero-info .schips { color: var(--gold); font-weight: 700; font-size: 15px; }
.hero .hero-info .sinfo { font-size: 12px; color: #9fe6c0; }

/* ---------------------------------------------------------- actions */
.actions {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 96px;
}
.actions .hint { color: var(--muted); text-align: center; padding: 18px 0; font-size: 14px; }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.action-row .btn { flex: 1; min-width: 110px; padding: 14px; font-weight: 700; font-size: 15px; }
.btn-fold { background: #33202a; border-color: #55303d; color: #ffb0b0; }
.btn-fold:hover:not(:disabled) { background: #43262f; }
.btn-call { background: linear-gradient(135deg, #1f8a52, #2ecc71); border: none; color: #04240f; }
.btn-call:hover:not(:disabled) { filter: brightness(1.08); }
.btn-raise { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; }
.btn-raise:hover:not(:disabled) { filter: brightness(1.08); }
.btn-allin { background: linear-gradient(135deg, #b7791f, var(--gold)); border: none; color: #241a00; }

.raise-box { margin-top: 12px; }
.raise-top {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
.raise-top b { color: var(--gold); font-size: 16px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.quick { display: flex; gap: 6px; margin-top: 8px; }
.quick button {
  flex: 1; background: var(--bg-2); border: 1px solid var(--line);
  color: var(--muted); border-radius: 8px; padding: 5px; font-size: 12px;
}
.quick button:hover { color: var(--text); border-color: #3a4759; }

/* ---------------------------------------------------------- panneaux */
.side { display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.panel h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel h3 code { color: var(--gold); letter-spacing: 3px; }

.seat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.seat-list li {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 14px;
}
.seat-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.seat-list .dot.off { background: #555; }
.seat-list .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-list .ch { color: var(--gold); font-weight: 600; font-size: 13px; }
.seat-list .tag {
  font-size: 10px; background: #2a3546; color: var(--muted);
  padding: 2px 6px; border-radius: 999px;
}
.seat-list .tag.host { background: #4a3a12; color: var(--gold); }

#lobby-box { margin-top: 12px; }
#lobby-box .btn { width: 100%; }
#lobby-box .note { color: var(--muted); font-size: 13px; text-align: center; margin: 8px 0 0; }

.chat-log, .game-log {
  height: 150px;
  overflow-y: auto;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 4px;
}
.game-log { height: 130px; color: var(--muted); }
.chat-log .m b { color: var(--accent); }
.chat-log .m.system { color: var(--muted); font-style: italic; }
#chat-form { display: flex; gap: 8px; margin-top: 10px; }
#chat-form input { padding: 9px 12px; }

/* ---------------------------------------------------------- overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, .72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 20px;
}
.overlay-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  width: min(520px, 100%);
  box-shadow: var(--shadow);
  max-height: 86vh;
  overflow-y: auto;
}
.overlay-card h2 { margin: 0 0 6px; text-align: center; }
.overlay-card .sub { text-align: center; color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.overlay-card .code-big {
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--gold);
  margin: 10px 0 18px;
  font-family: ui-monospace, Consolas, monospace;
}
.overlay-actions { display: flex; gap: 10px; margin-top: 18px; }
.overlay-actions .btn { flex: 1; }

.result-line {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: var(--panel-2);
  margin-bottom: 6px; font-size: 14px;
}
.result-line .win { color: var(--green); font-weight: 700; }
.result-hands {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin: 14px 0;
}
.result-hand {
  background: var(--panel-2); border-radius: 10px; padding: 8px 10px;
  text-align: center; font-size: 13px;
}
.result-hand .cards { display: flex; gap: 4px; justify-content: center; margin-bottom: 6px; }
.result-hand .hn { color: var(--muted); font-size: 12px; }
.result-hand.winner { border: 1px solid var(--gold); }

.countdown { text-align: center; color: var(--muted); font-size: 14px; margin-top: 14px; }

/* ---------------------------------------------------------- toast */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a1418;
  border: 1px solid #6b2f38;
  color: #ffb3b3;
  padding: 12px 20px;
  border-radius: 10px;
  z-index: 40;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: pop .2s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }
