:root {
  --felt: #0f5132;
  --felt-dark: #0a3a24;
  --felt-deep: #072818;
  --felt-light: #157347;
  --wood: #5a3418;
  --wood-light: #8a5a2b;
  --ivory: #f6f0dc;
  --ivory-dim: #cfc8b0;
  --gold: #d4af37;
  --gold-soft: #e9cf74;
  --red: #c0392b;
  --red-soft: #e46a5c;
  --panel: rgba(4, 30, 18, 0.72);
  --panel-border: rgba(212, 175, 55, 0.28);
  --line: rgba(246, 240, 220, 0.12);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--ivory);
  background-color: var(--felt-dark);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(30, 140, 80, 0.45), transparent 60%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, 0.5), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255,255,255,0.012) 0 2px, transparent 2px 4px);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold-soft); }
h1, h2, h3 { font-family: "Playfair Display", Georgia, serif; margin: 0; letter-spacing: 0.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--ivory-dim); }
.small { font-size: 0.85rem; }
.gold { color: var(--gold); }
.pos { color: #7be0a0; }
.neg { color: var(--red-soft); }
.loading { text-align: center; padding: 4rem 1rem; color: var(--ivory-dim); }
[hidden] { display: none !important; }

/* ------ Barres ------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(180deg, var(--wood) 0%, #3f220e 100%);
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.brand { font-family: "Playfair Display", serif; font-weight: 800; font-size: 1.25rem; color: var(--ivory); text-decoration: none; white-space: nowrap; }
.brand .suit { color: var(--gold); }
.topnav { display: flex; gap: 0.25rem; }
.topnav a { color: var(--ivory-dim); text-decoration: none; padding: 0.45rem 0.8rem; border-radius: 999px; font-weight: 500; font-size: 0.95rem; }
.topnav a.active { background: rgba(212,175,55,0.18); color: var(--gold-soft); }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: none; grid-template-columns: repeat(4, 1fr);
  padding: 0.35rem 0.25rem calc(0.35rem + var(--safe-b));
  background: linear-gradient(180deg, #4a2913, var(--wood));
  border-top: 2px solid var(--gold);
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--ivory-dim); text-decoration: none; font-size: 0.72rem; padding: 0.25rem 0; }
.bottomnav a span { font-size: 1.2rem; line-height: 1; }
.bottomnav a.active { color: var(--gold-soft); }

@media (max-width: 720px) {
  .topnav { display: none; }
  .topbar { justify-content: center; padding: 0.65rem 1rem; }
  .bottomnav { display: grid; }
  .app { padding-bottom: calc(5.5rem + var(--safe-b)); }
}

/* ------ Mise en page ------ */
.app { max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.25rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}
.card h2, .card h3 { margin-bottom: 0.65rem; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.65rem; flex-wrap: wrap; }
.card-title h2, .card-title h3 { margin: 0; }

/* ------ Formulaires ------ */
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.88rem; color: var(--ivory-dim); font-weight: 500; }
input, select {
  font: inherit; font-size: 1rem; color: var(--ivory);
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(246,240,220,0.22);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  width: 100%;
  min-height: 46px;
}
input:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
input::placeholder { color: rgba(246,240,220,0.4); }
.check { flex-direction: row; align-items: center; gap: 0.6rem; color: var(--ivory); font-size: 1rem; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--gold); }

.btn {
  font: inherit; font-weight: 600; font-size: 0.98rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.7rem 1.1rem; min-height: 44px;
  border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-gold { background: linear-gradient(180deg, var(--gold-soft), var(--gold)); color: #2a1a05; box-shadow: 0 3px 0 #8a6d16; }
.btn-gold:hover { filter: brightness(1.06); }
.btn-red { background: linear-gradient(180deg, var(--red-soft), var(--red)); color: #fff; box-shadow: 0 3px 0 #7d2219; }
.btn-ghost { background: transparent; color: var(--ivory); border-color: rgba(246,240,220,0.3); }
.btn-ghost:hover { background: rgba(246,240,220,0.06); }
.btn-sm { padding: 0.35rem 0.75rem; min-height: 34px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-xl { font-size: 1.25rem; padding: 1rem 1.5rem; min-height: 60px; }
.linkbtn { background: none; border: none; color: var(--gold-soft); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* ------ Auth ------ */
.auth { max-width: 430px; margin: 2rem auto 0; }
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.auth-logo .suits { font-size: 2rem; letter-spacing: 0.4rem; }
.auth-logo .suits .r { color: var(--red-soft); }
.auth-logo h1 { font-size: 2.2rem; margin-top: 0.3rem; }
.auth-foot { text-align: center; margin-top: 1rem; font-size: 0.95rem; }

/* ------ Listes ------ */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.8rem 0.1rem; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.list-item:last-child { border-bottom: none; }
a.list-item:hover { background: rgba(255,255,255,0.03); }
.list-item .main { min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .sub { font-size: 0.84rem; color: var(--ivory-dim); margin-top: 2px; }
.empty { color: var(--ivory-dim); text-align: center; padding: 1.25rem 0.5rem; }

.badge { white-space: nowrap; display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.72rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 999px; letter-spacing: 0.02em; text-transform: uppercase; }
.badge-live { background: rgba(123,224,160,0.15); color: #7be0a0; border: 1px solid rgba(123,224,160,0.4); }
.badge-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7be0a0; animation: pulse 1.6s infinite; }
.badge-done { background: rgba(246,240,220,0.08); color: var(--ivory-dim); border: 1px solid var(--line); }
.badge-gold { background: rgba(212,175,55,0.15); color: var(--gold-soft); border: 1px solid rgba(212,175,55,0.4); }
.badge-red { background: rgba(192,57,43,0.18); color: var(--red-soft); border: 1px solid rgba(192,57,43,0.45); }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ------ Table de poker ------ */
.table-wrap { position: relative; width: 100%; aspect-ratio: 16 / 10; margin: 0.25rem 0 0.5rem; }
@media (max-width: 560px) { .table-wrap { aspect-ratio: 4 / 5; } }
.poker-table {
  position: absolute; inset: 13% 11%;
  border-radius: 50% / 50%;
  background: radial-gradient(ellipse at 50% 40%, var(--felt-light) 0%, var(--felt) 55%, var(--felt-dark) 100%);
  border: 14px solid var(--wood);
  box-shadow: inset 0 0 0 3px var(--wood-light), inset 0 0 40px rgba(0,0,0,0.5), 0 0 0 3px #2b1607, 0 18px 40px rgba(0,0,0,0.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
@media (max-width: 560px) { .poker-table { inset: 13% 19%; border-width: 10px; } }
.poker-table .pot-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.15em; color: rgba(246,240,220,0.65); }
.poker-table .pot { font-family: "Playfair Display", serif; font-size: clamp(1.4rem, 4.5vw, 2.2rem); font-weight: 800; color: var(--gold-soft); }
.poker-table .pot-sub { font-size: 0.78rem; color: rgba(246,240,220,0.7); }

.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: clamp(76px, 15vw, 112px);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-align: center; z-index: 2;
}
.seat .avatar {
  width: clamp(40px, 8vw, 54px); height: clamp(40px, 8vw, 54px); border-radius: 50%;
  display: grid; place-items: center;
  font-family: "Playfair Display", serif; font-weight: 800; font-size: clamp(1rem, 3vw, 1.3rem);
  background: linear-gradient(160deg, var(--ivory), var(--ivory-dim)); color: var(--felt-deep);
  border: 3px solid var(--wood-light); box-shadow: 0 4px 10px rgba(0,0,0,0.45);
  position: relative;
}
.seat.me .avatar { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,175,55,0.35), 0 4px 10px rgba(0,0,0,0.45); }
.seat.left .avatar { opacity: 0.45; filter: grayscale(0.8); }
.seat .name { font-weight: 700; font-size: clamp(0.72rem, 2.4vw, 0.9rem); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.seat .amt { font-size: clamp(0.66rem, 2.1vw, 0.8rem); color: var(--gold-soft); font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.chip {
  position: absolute; top: -10px; right: -16px;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.62rem; font-weight: 800; letter-spacing: -0.02em;
  border: 2px dashed rgba(255,255,255,0.75);
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
.chip + .chip { right: auto; left: -16px; }
.chip-d { background: #fff; color: #111; border-color: #999; }
.chip-sb { background: #1f5fbf; color: #fff; }
.chip-bb { background: var(--red); color: #fff; }
.legend { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; font-size: 0.8rem; color: var(--ivory-dim); }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend .chip { position: static; width: 20px; height: 20px; font-size: 0.55rem; }

/* ------ Partie ------ */
.my-panel { text-align: center; }
.my-panel .big { font-family: "Playfair Display", serif; font-size: 2.2rem; font-weight: 800; color: var(--gold-soft); line-height: 1.1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; text-align: center; }
.stat { background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.3rem; }
.stat .v { font-weight: 800; font-size: 1.15rem; }
.stat .l { font-size: 0.72rem; color: var(--ivory-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

.players { display: flex; flex-direction: column; }
.player { border-bottom: 1px solid var(--line); padding: 0.75rem 0; }
.player:last-child { border-bottom: none; }
.player-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.player-name { font-weight: 700; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.player-nums { text-align: right; font-size: 0.86rem; white-space: nowrap; }
.player-nums b { font-size: 1rem; }
.player-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.55rem; }
.buyin-list { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.3rem; }
.buyin { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; font-size: 0.85rem; padding: 0.35rem 0.6rem; background: rgba(0,0,0,0.22); border-radius: 8px; }
.buyin.cancelled { opacity: 0.55; text-decoration: line-through; }

.diff { border-radius: 12px; padding: 0.75rem 0.9rem; font-weight: 600; }
.diff.ok { background: rgba(123,224,160,0.12); border: 1px solid rgba(123,224,160,0.4); color: #a9f0c3; }
.diff.bad { background: rgba(192,57,43,0.15); border: 1px solid rgba(192,57,43,0.5); color: #f3b0a8; }
.diff.wait { background: rgba(212,175,55,0.1); border: 1px solid rgba(212,175,55,0.35); color: var(--gold-soft); }

.settle { display: flex; flex-direction: column; gap: 0.6rem; }
.settle-item { background: rgba(0,0,0,0.25); border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 0.9rem; }
.settle-item.paid { opacity: 0.6; }
.settle-item.mine { border-color: var(--gold); }
.settle-line { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.settle-who { font-weight: 600; }
.settle-amt { font-family: "Playfair Display", serif; font-weight: 800; font-size: 1.35rem; color: var(--gold-soft); }
.settle-tools { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin-top: 0.55rem; }
.phone { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

.results-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.results-table th { text-align: left; font-weight: 600; color: var(--ivory-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.4rem 0.3rem; border-bottom: 1px solid var(--line); }
.results-table td { padding: 0.55rem 0.3rem; border-bottom: 1px solid var(--line); }
.results-table tr:last-child td { border-bottom: none; }
.results-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.rank { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; font-size: 0.85rem; background: rgba(246,240,220,0.08); flex-shrink: 0; }
.rank-1 { background: linear-gradient(160deg, var(--gold-soft), var(--gold)); color: #2a1a05; }
.rank-2 { background: linear-gradient(160deg, #e9e9e9, #a9a9a9); color: #222; }
.rank-3 { background: linear-gradient(160deg, #e0a26a, #a0612b); color: #1d0f04; }

.pick-list { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.15rem; margin-top: 0.5rem; }
.pick-list .check { padding: 0.55rem 0.4rem; border-radius: 8px; }
.pick-list .check:hover { background: rgba(255,255,255,0.04); }
.guest-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.5rem; align-items: center; margin-top: 0.5rem; }
@media (max-width: 520px) { .guest-row { grid-template-columns: 1fr 1fr 40px; } }

/* ------ Toast & modal ------ */
.toast {
  position: fixed; left: 50%; bottom: calc(5.5rem + var(--safe-b)); transform: translate(-50%, 20px);
  background: var(--ivory); color: var(--felt-deep); font-weight: 600;
  padding: 0.75rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 50; max-width: calc(100% - 2rem); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red); color: #fff; }
@media (min-width: 721px) { .toast { bottom: 2rem; } }

.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center; padding: 1rem; }
@media (min-width: 600px) { .modal { align-items: center; } }
.modal-box { width: 100%; max-width: 440px; background: var(--felt-deep); border: 1px solid var(--panel-border); border-radius: 18px; padding: 1.25rem; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; }
.modal-box h3 { margin-bottom: 0.8rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

.reveal { animation: reveal .6s ease both; }
@keyframes reveal { from { opacity: 0; transform: translate(-50%, -50%) scale(0.4); } }
.banner { background: linear-gradient(90deg, rgba(212,175,55,0.2), rgba(212,175,55,0.05)); border: 1px solid rgba(212,175,55,0.45); border-radius: 12px; padding: 0.75rem 1rem; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 0.25rem 0; }

@media (max-width: 520px) { .hide-sm { display: none; } .results-table { font-size: 0.86rem; } }
.card { overflow-x: auto; }
