:root {
  --bg: #0b1210;
  --bg-2: #111c18;
  --panel: #15221d;
  --panel-2: #1b2b25;
  --line: #26392f;
  --text: #ecf2ee;
  --muted: #8fa59a;
  --gold: #f4d58d;
  --gold-2: #e0b65a;
  --green: #1f8f5f;
  --green-2: #27b277;
  --red: #e5484d;
  --blue: #5b8def;
  --discord: #5865f2;
  --felt: #17603f;
  --felt-2: #0e4a30;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #173327 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.15; }
h1 { font-size: clamp(26px, 4vw, 40px); font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.gold { color: var(--gold); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.boot { display: grid; place-items: center; height: 100vh; font-size: 64px; color: var(--gold); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* ---------- Boutons et formulaires ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 10px 16px; border-radius: 10px; cursor: pointer; font-weight: 600;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s; white-space: nowrap;
  text-decoration: none !important;
}
.btn:hover { border-color: #3a5547; background: #213630; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--green-2), var(--green)); border-color: #2fc483; color: #04140c; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.gold { background: linear-gradient(180deg, var(--gold), var(--gold-2)); border-color: #f7df9f; color: #2a1d00; }
.btn.danger { background: #3a1517; border-color: #6a2226; color: #ffb4b6; }
.btn.discord { background: var(--discord); border-color: #7480ff; color: #fff; }
.btn.google { background: #fff; color: #1f1f1f; border-color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 22px; font-size: 17px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.active { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); color: var(--gold); }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=number], input[type=search], select, textarea {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--green-2); }
input[type=range] { width: 100%; accent-color: var(--gold); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { width: 18px; height: 18px; accent-color: var(--green-2); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Mise en page ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 10px 20px; background: rgba(11, 18, 16, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); letter-spacing: .3px; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--felt); display: grid; place-items: center; color: var(--gold); font-size: 18px; box-shadow: inset 0 0 0 1px #2a7a55; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.chips-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); padding: 6px 12px; border-radius: 99px; font-weight: 700; color: var(--gold); }
.chip-icon { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle, var(--gold) 35%, #b8872e 36%, #b8872e 55%, var(--gold) 56%); display: inline-block; flex: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--panel-2); display: inline-grid; place-items: center; font-weight: 700; color: var(--gold); flex: none; overflow: hidden; }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; }
.user-btn { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; padding: 4px; border-radius: 99px; }
.user-btn:hover { background: var(--panel); }

.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card-panel { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-panel h2 { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.banner { background: linear-gradient(90deg, #3b2f0e, #2a2410); border: 1px solid #6b5520; color: var(--gold); padding: 10px 16px; border-radius: 10px; margin-bottom: 18px; display: flex; gap: 10px; align-items: center; }
.empty { color: var(--muted); text-align: center; padding: 20px; border: 1px dashed var(--line); border-radius: 10px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.badge.green { color: #7ee2b2; border-color: #22694a; background: #0f2f22; }
.badge.gold { color: var(--gold); border-color: #6b5520; background: #2a2410; }
.badge.red { color: #ffb4b6; border-color: #6a2226; background: #2c1214; }

/* ---------- Connexion ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(440px, 100%); text-align: center; }
.login-card .logo-xl { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 18px; background: var(--felt); display: grid; place-items: center; font-size: 46px; color: var(--gold); box-shadow: 0 0 0 1px #2a7a55, 0 20px 60px rgba(31, 143, 95, .35); }
.login-card .btn { margin-top: 10px; }
.suits { letter-spacing: 10px; color: var(--muted); font-size: 22px; margin: 6px 0 18px; }
.suits .r { color: var(--red); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 6px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- Accueil / jeux ---------- */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.game-card { position: relative; border-radius: 18px; padding: 26px; min-height: 210px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; border: 1px solid var(--line); cursor: pointer; transition: transform .15s, box-shadow .15s; background: var(--panel); color: var(--text); text-decoration: none !important; }
.game-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(0, 0, 0, .45); }
.game-card.poker { background: radial-gradient(circle at 70% 20%, #23845a, var(--felt-2) 70%); border-color: #2a7a55; }
.game-card.soon { cursor: default; opacity: .55; filter: grayscale(.6); }
.game-card.soon:hover { transform: none; box-shadow: none; }
.game-card .icon { position: absolute; top: 14px; right: 20px; font-size: 90px; opacity: .25; color: var(--gold); }
.game-card h2 { font-size: 26px; margin: 0; }

/* ---------- Listes ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
table.data tr:hover td { background: rgba(255, 255, 255, .02); }
.rank { width: 26px; text-align: center; font-weight: 800; color: var(--muted); }
.rank.top { color: var(--gold); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; color: var(--muted); cursor: pointer; font-weight: 600; white-space: nowrap; }
.tabs button.active { color: var(--text); border-color: var(--gold); }
.stat { padding: 16px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.stat .v { font-size: 26px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; }

/* ---------- Modales et notifications ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { width: min(480px, 100%); max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); animation: pop .18s; }
.modal h2 { margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
#toasts { position: fixed; top: 70px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--green-2); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; animation: slidein .2s; }
.toast.error { border-left-color: var(--red); }
.toast.gold { border-left-color: var(--gold); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }
.copy-box { display: flex; gap: 8px; }
.copy-box input { font-family: ui-monospace, monospace; font-size: 13px; }

/* ---------- Cartes à jouer ---------- */
.pcard {
  --w: 46px; width: var(--w); height: calc(var(--w) * 1.4); border-radius: calc(var(--w) * .12);
  background: linear-gradient(180deg, #fff, #eef0f2); color: #111; position: relative; flex: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4); display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  padding: calc(var(--w) * .07) calc(var(--w) * .1); font-weight: 700; line-height: 1; user-select: none;
  animation: deal .25s ease-out;
}
.pcard .r { font-size: calc(var(--w) * .42); letter-spacing: -1px; }
.pcard .s { font-size: calc(var(--w) * .38); }
.pcard .big { position: absolute; right: calc(var(--w) * .08); bottom: calc(var(--w) * .04); font-size: calc(var(--w) * .62); opacity: .9; }
.pcard.red { color: #d12b33; }
.pcard.back { background: repeating-linear-gradient(45deg, #8c1d2a 0 4px, #a6283a 4px 8px); border: 2px solid #fff; }
.pcard.back > * { display: none; }
.pcard.ghost { background: rgba(255, 255, 255, .05); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); animation: none; }
.pcard.dim { filter: brightness(.5); }
.pcard.hl { box-shadow: 0 0 0 2px var(--gold), 0 0 16px rgba(244, 213, 141, .6); transform: translateY(-4px); }
@keyframes deal { from { transform: translateY(-14px) scale(.9); opacity: 0; } }

/* ---------- Salle de jeu ---------- */
.room { display: grid; grid-template-columns: 1fr 320px; height: calc(100vh - 57px); height: calc(100dvh - 57px); }
.room-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.room-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.room-head .title { font-weight: 700; font-size: 17px; }
.code-tag { font-family: ui-monospace, monospace; background: var(--bg-2); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; letter-spacing: 2px; color: var(--gold); font-size: 13px; }
.stage { flex: 1; position: relative; min-height: 0; display: grid; place-items: center; padding: 30px 20px 10px; }
.felt {
  position: relative; width: min(100%, 980px); aspect-ratio: 2.05 / 1; max-height: 100%;
  border-radius: 999px; background: radial-gradient(ellipse at center, #1f7a51 0%, var(--felt) 45%, var(--felt-2) 100%);
  box-shadow: 0 0 0 12px #3b2416, 0 0 0 14px #5a3a22, 0 0 0 16px #1c110a, 0 30px 60px rgba(0, 0, 0, .6), inset 0 0 80px rgba(0, 0, 0, .45);
}
.felt::after { content: 'TABLEGAMES'; position: absolute; left: 50%; top: 68%; transform: translateX(-50%); color: rgba(255, 255, 255, .06); font-weight: 800; letter-spacing: 8px; font-size: clamp(12px, 2vw, 22px); pointer-events: none; }
.center { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.board { display: flex; gap: 6px; }
.board .pcard { --w: clamp(38px, 5.2vw, 60px); }
.pot { background: rgba(0, 0, 0, .35); border-radius: 99px; padding: 4px 14px; font-weight: 700; display: flex; gap: 6px; align-items: center; color: var(--gold); }
.pot .side { color: var(--muted); font-weight: 500; font-size: 12px; }
.table-msg { font-size: 14px; color: #d6eadf; background: rgba(0, 0, 0, .3); padding: 4px 12px; border-radius: 99px; text-align: center; max-width: 320px; }

.seat { position: absolute; transform: translate(-50%, -50%); width: 128px; display: flex; flex-direction: column; align-items: center; z-index: 2; }
.seat .hole { display: flex; gap: 3px; height: 50px; margin-bottom: -16px; z-index: 1; }
.seat .hole .pcard { --w: 38px; }
.seat.me .hole .pcard { --w: 46px; }
.seat.me .hole { height: 62px; }
.seat .plate {
  position: relative; width: 100%; background: rgba(10, 16, 14, .92); border: 1px solid #2f463b; border-radius: 12px;
  padding: 18px 8px 6px; text-align: center; z-index: 2; box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
}
.seat .plate .avatar { width: 34px; height: 34px; position: absolute; left: 50%; top: -18px; transform: translateX(-50%); border: 2px solid #2f463b; font-size: 14px; }
.seat .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.seat .stack { color: var(--gold); font-weight: 700; font-size: 13px; }
.seat .tag { position: absolute; top: -10px; right: -6px; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); text-transform: uppercase; }
.seat .last { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: #22313a; text-transform: uppercase; white-space: nowrap; z-index: 3; }
.seat .last.fold { background: #3a2023; color: #ffb4b6; }
.seat .last.raise, .seat .last.bet, .seat .last.allin { background: #4a3a10; color: var(--gold); }
.seat .last.call, .seat .last.check { background: #163a2a; color: #9ae6c1; }
.seat.folded { opacity: .45; }
.seat.out { opacity: .5; }
.seat.turn .plate { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(244, 213, 141, .4), 0 0 24px rgba(244, 213, 141, .35); }
.seat.winner .plate { border-color: var(--green-2); box-shadow: 0 0 0 2px rgba(39, 178, 119, .5), 0 0 30px rgba(39, 178, 119, .5); }
.seat .timer { position: absolute; left: 6px; right: 6px; bottom: 2px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.seat .timer i { display: block; height: 100%; background: var(--gold); width: 100%; transform-origin: left; }
.seat .hand-name { font-size: 11px; color: #9ae6c1; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .win-amt { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); color: #7ee2b2; font-weight: 800; font-size: 16px; text-shadow: 0 2px 6px #000; animation: rise 1s ease-out; white-space: nowrap; z-index: 5; }
@keyframes rise { from { transform: translate(-50%, 12px); opacity: 0; } }
.seat.free .plate { background: rgba(0, 0, 0, .25); border-style: dashed; cursor: pointer; color: var(--muted); padding: 14px 8px; }
.seat.free .plate:hover { border-color: var(--gold); color: var(--gold); }
.seat.free .hole { display: none; }
.bet-chip { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 5px; background: rgba(0, 0, 0, .45); padding: 3px 9px 3px 4px; border-radius: 99px; font-weight: 700; font-size: 13px; color: #fff; z-index: 1; white-space: nowrap; }
.dealer-btn { position: absolute; transform: translate(-50%, -50%); width: 24px; height: 24px; border-radius: 50%; background: #fff; color: #111; font-weight: 800; font-size: 12px; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); z-index: 1; transition: left .4s, top .4s; }

.actionbar { border-top: 1px solid var(--line); padding: 12px 16px calc(12px + var(--safe-b)); background: rgba(11, 18, 16, .9); display: flex; flex-direction: column; gap: 10px; min-height: 74px; justify-content: center; }
.actionbar .main-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actionbar .main-actions .btn { flex: 1; min-width: 110px; padding: 14px 10px; font-size: 16px; }
.raise-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.raise-box input[type=number] { width: 110px; }
.raise-box .presets { display: flex; gap: 4px; flex-wrap: wrap; }
.raise-box input[type=range] { flex: 1; min-width: 140px; }
.waiting-msg { color: var(--muted); text-align: center; }

.side { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); }
.side .tabs { margin: 0; padding: 0 8px; }
.side .pane { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chat-msg { font-size: 14px; line-height: 1.35; word-wrap: break-word; }
.chat-msg b { color: var(--gold); font-weight: 600; }
.chat-msg.system { color: var(--muted); font-style: italic; font-size: 13px; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.log-line { font-size: 13px; color: #c7d6ce; }
.log-line.sep { color: var(--gold); margin-top: 6px; font-weight: 600; }

.mobile-only { display: none; }

@media (max-width: 960px) {
  .room { grid-template-columns: 1fr; }
  .side { position: fixed; right: 0; top: 57px; bottom: 0; width: min(360px, 92vw); z-index: 30; transform: translateX(100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .mobile-only { display: inline-flex; }
}
@media (max-width: 720px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar nav { display: none; }
  .brand span.txt { display: none; }
  .page { padding: 18px 14px 50px; }
  .stage { padding: 40px 6px 30px; }
  .felt { aspect-ratio: 1 / 1.35; border-radius: 160px; width: min(100%, 440px); }
  .felt::after { top: 64%; }
  .seat { width: 94px; }
  .seat .hole .pcard { --w: 28px; }
  .seat .hole { height: 38px; margin-bottom: -12px; }
  .seat.me .hole .pcard { --w: 40px; }
  .seat.me .hole { height: 56px; }
  .seat .name, .seat .stack { font-size: 12px; }
  .board .pcard { --w: 42px; }
  .board { gap: 4px; }
  .actionbar .main-actions .btn { min-width: 0; font-size: 14px; padding: 12px 6px; }
}
