:root {
  --felt: #0e3b2c;
  --felt-2: #0a2c21;
  --felt-3: #14503b;
  --line: #ffffff1c;
  --paper: #f6f0e1;
  --ink: #17201b;
  --red: #c43b2f;
  --gold: #f0b429;
  --blue: #5ab3ff;
  --text: #e9f3ec;
  --muted: #9bb8a8;
  --danger: #e5533d;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--felt-2); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.screen { height: 100dvh; display: flex; flex-direction: column; }
.scroll { overflow-y: auto; padding: 12px 14px 20px; flex: 1; min-height: 0; }
h1 { margin: 0; font-size: 26px; letter-spacing: -0.01em; }
h3 { margin: 0 0 8px; font-size: 15px; }

/* boutons */
.btn { background: #ffffff14; border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; font-weight: 600; min-height: 44px; }
.btn.primary { background: var(--gold); color: #2a1d00; border-color: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.big { min-height: 52px; font-size: 17px; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.45; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.icon-btn { background: transparent; border: 0; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--text); }
.icon-btn:active { background: #ffffff18; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px; font-size: 14px; }

/* accueil */
#home { align-items: center; justify-content: center; background: radial-gradient(120% 80% at 50% 0%, var(--felt-3), var(--felt-2)); }
.home-inner { width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px; padding: 20px 0; }
.logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 8px 24px #0007; margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input, textarea { background: #00000033; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; width: 100%; min-height: 48px; outline: none; }
input:focus, textarea:focus { border-color: var(--gold); }
textarea { resize: none; min-height: 84px; }
.or { text-align: center; color: var(--muted); font-size: 13px; position: relative; }
.or::before, .or::after { content: ""; position: absolute; top: 50%; width: 38%; height: 1px; background: var(--line); }
.or::before { left: 0; } .or::after { right: 0; }
.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: 0.25em; text-align: center; font-weight: 700; font-size: 18px; }
.error { color: #ff9b8a; margin: 0; font-size: 14px; }

/* en-tête */
#top { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 12px; padding-top: max(4px, env(safe-area-inset-top)); background: var(--felt-2); border-bottom: 1px solid var(--line); min-height: 52px; }
.code-chip { background: #ffffff14; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-weight: 800; letter-spacing: 0.18em; font-size: 15px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #e5533d; margin-right: 6px; }
.dot.on { background: #46d17f; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; background: radial-gradient(120% 70% at 50% 0%, var(--felt-3), var(--felt) 60%); }
.tab { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#tab-table > #board { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#tab-table > #lobby { flex: 1; }
#lobbyStart { margin-bottom: 12px; }
#tabs { display: flex; background: var(--felt-2); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; background: none; border: 0; padding: 14px 2px; font-size: 15px; color: var(--muted); font-weight: 600; position: relative; }
#tabs button.on { color: var(--gold); box-shadow: inset 0 2px 0 var(--gold); }
.badge { position: absolute; top: 6px; margin-left: 4px; background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; font-weight: 700; }

/* panneaux */
.panel { background: #00000026; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.panel.accent { border-color: var(--gold); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.code { font-size: 30px; font-weight: 800; letter-spacing: 0.22em; }
.player-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.player-row:first-of-type { border-top: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--felt-3); border: 2px solid var(--line); display: grid; place-items: center; font-weight: 800; flex: none; position: relative; }
.avatar .on { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: #46d17f; border: 2px solid var(--felt); }
.hearts { color: #ff7a6b; font-size: 14px; letter-spacing: 1px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.toggle input { width: 22px; height: 22px; min-height: 0; accent-color: var(--gold); }
.log-line { font-size: 14px; color: var(--muted); padding: 2px 0; }

/* table de jeu */
#seats { display: flex; gap: 8px; padding: 10px 10px 4px; justify-content: center; flex-wrap: wrap; }
.seat { display: flex; align-items: center; gap: 8px; background: #00000030; border: 2px solid transparent; border-radius: 40px; padding: 4px 12px 4px 4px; min-width: 0; }
.seat.turn { border-color: var(--gold); background: #f0b42922; }
.seat .avatar { width: 34px; height: 34px; font-size: 14px; }
.seat .nm { font-weight: 700; font-size: 14px; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .ct { font-size: 12px; color: var(--muted); }
.seat .ct b { color: var(--text); }
#center { flex: 1; min-height: 120px; display: flex; align-items: center; justify-content: center; gap: 22px; padding: 6px; position: relative; }
.pile { position: relative; }
.pile .label { position: absolute; left: 0; right: 0; bottom: -20px; text-align: center; font-size: 12px; color: var(--muted); }
.suit-chip { position: absolute; right: -14px; top: -14px; width: 34px; height: 34px; border-radius: 50%; background: var(--paper); color: var(--ink); display: grid; place-items: center; font-size: 20px; box-shadow: 0 2px 6px #0009; border: 2px solid var(--gold); }
.suit-chip.red { color: var(--red); }
.pending { position: absolute; left: -16px; top: -12px; background: var(--danger); color: #fff; font-weight: 800; border-radius: 16px; padding: 3px 11px; font-size: 18px; box-shadow: 0 2px 6px #0009; animation: pop 0.4s; }
.dirmark { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }
@keyframes pop { from { transform: scale(0.6); } to { transform: scale(1); } }
#journal { padding: 2px 14px 6px; min-height: 64px; }
#journal div { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#journal div:last-child { color: var(--text); }
#notice { padding: 0 12px; }
.notice { border-radius: 12px; padding: 10px 14px; font-weight: 600; text-align: center; background: #00000030; }
.notice.me { background: var(--gold); color: #2a1d00; }
.notice.cut { background: #5ab3ff2a; color: #cfe9ff; border: 1px solid var(--blue); }
.notice.life { background: #00000050; border: 1px solid var(--gold); text-align: left; font-weight: 500; }
.notice .row { margin-top: 10px; }
.notice .row .btn { flex: 1; }
.turnbar { height: 6px; border-radius: 3px; background: #ffffff1f; margin: 6px 2px 0; overflow: hidden; }
.turnbar i { display: block; height: 100%; width: 100%; background: var(--gold); transition: width 0.1s linear; }
.turnbar i.low { background: var(--danger); }
.turn-note { text-align: center; margin-top: 6px; }
#actions { display: flex; gap: 8px; padding: 8px 12px 0; align-items: center; flex-wrap: wrap; }
#actions .btn.big { flex: 1; }
#actions .minor { display: flex; gap: 2px; margin-left: auto; }

/* cartes */
.card { width: 60px; height: 88px; border-radius: 9px; background: var(--paper); color: var(--ink); border: 0; position: relative; box-shadow: 0 2px 6px #0009; flex: none; padding: 0; font-weight: 700; font-family: Georgia, "Times New Roman", serif; transition: transform 0.12s; }
.card.red { color: var(--red); }
.card .rk { position: absolute; top: 5px; left: 7px; font-size: 18px; line-height: 1; }
.card .st { position: absolute; top: 24px; left: 7px; font-size: 14px; line-height: 1; }
.card .big { position: absolute; right: 7px; bottom: 5px; font-size: 32px; line-height: 1; }
.card.lg { width: 74px; height: 108px; border-radius: 11px; }
.card.lg .rk { font-size: 22px; } .card.lg .st { top: 29px; font-size: 17px; } .card.lg .big { font-size: 40px; }
.card.mini { width: 34px; height: 48px; border-radius: 6px; }
.card.mini .rk { font-size: 13px; top: 3px; left: 4px; } .card.mini .st { display: none; } .card.mini .big { font-size: 17px; right: 4px; bottom: 3px; }
.card.back { background: repeating-linear-gradient(45deg, #1d6b50 0 6px, #175a43 6px 12px); border: 3px solid var(--paper); display: grid; place-items: center; color: var(--paper); font-size: 20px; }
.hand { display: flex; overflow-x: auto; padding: 22px 16px calc(14px + 4px); min-height: 134px; align-items: flex-end; scrollbar-width: none; }
.hand::-webkit-scrollbar { display: none; }
.hand .card { margin-left: -22px; }
.hand .card:first-child { margin-left: 0; }
.hand .card.dim { filter: brightness(0.74); }
.hand .card.play { transform: translateY(-16px); box-shadow: 0 0 0 3px var(--gold), 0 8px 14px #000a; }
.hand .card.cut { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--blue), 0 8px 14px #000a; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #5ab3ff55, 0 8px 14px #000a; } }
.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* tirage */
.draw-rounds { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.draw-round { display: flex; gap: 10px; flex-wrap: wrap; }
.draw-item { display: flex; align-items: center; gap: 8px; background: #00000030; border-radius: 10px; padding: 4px 10px 4px 4px; border: 2px solid transparent; }
.draw-item.win { border-color: var(--gold); }

/* vote */
#voteBar { background: #2a2210; border-bottom: 1px solid var(--gold); padding: 8px 12px; }
#voteBar:empty { display: none; }
#voteBar .q { font-weight: 600; margin-bottom: 6px; }
#voteBar .row .btn { flex: 1; min-height: 40px; padding: 6px; }
.tally { font-size: 13px; color: var(--muted); }

/* chat */
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 16px; background: #00000040; align-self: flex-start; word-break: break-word; }
.msg.mine { align-self: flex-end; background: #f0b42933; border-bottom-right-radius: 4px; }
.msg:not(.mine) { border-bottom-left-radius: 4px; }
.msg .who { font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 1px; }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 13px; text-align: center; max-width: 94%; padding: 2px 8px; }
.msg .t { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.voice .pp { width: 38px; height: 38px; border-radius: 50%; background: var(--gold); color: #2a1d00; border: 0; display: grid; place-items: center; flex: none; }
.voice .bar { flex: 1; height: 5px; border-radius: 3px; background: #ffffff25; overflow: hidden; }
.voice .bar i { display: block; height: 100%; width: 0; background: var(--text); }
.voice .dur { font-size: 12px; color: var(--muted); min-width: 30px; text-align: right; }
.voice.gone { opacity: 0.5; }
.chat-form { display: flex; align-items: center; gap: 4px; padding: 6px 8px 8px; background: var(--felt-2); border-top: 1px solid var(--line); }
.chat-form input { flex: 1; border-radius: 22px; min-height: 44px; }
.chat-form .icon-btn.send { background: var(--gold); color: #2a1d00; border-radius: 50%; }
.chat-form .icon-btn.mic { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chat-form .icon-btn.mic.rec { background: var(--danger); color: #fff; border-radius: 50%; transform: scale(1.25); }
.chat-form.has-text .mic { display: none; }
.chat-form:not(.has-text) .send { display: none; }
.rec-bar { display: flex; gap: 10px; align-items: center; padding: 8px 14px; background: #3a1a14; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse2 1s infinite; }
@keyframes pulse2 { 50% { opacity: 0.3; } }

/* règles / classement */
.rules-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.rules-list b { color: var(--gold); }
.house { border-top: 1px solid var(--line); padding: 8px 0; }
.house:first-of-type { border-top: 0; }
.house .by { font-size: 12px; color: var(--muted); }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.rank-row:first-of-type { border-top: 0; }
.rank-row .pos { width: 22px; text-align: center; font-weight: 800; color: var(--muted); }
.rank-row.first .pos { color: var(--gold); }
.rank-row .grow { flex: 1; font-weight: 700; }
.rank-row .n { font-weight: 800; font-size: 18px; }

/* feuille modale */
.sheet { position: fixed; inset: 0; background: #000a; display: flex; align-items: flex-end; z-index: 20; }
.sheet-card { width: 100%; background: var(--felt-2); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.sheet-card h2 { margin: 0; font-size: 19px; }
.suits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.suits button { aspect-ratio: 1; border-radius: 16px; border: 0; background: var(--paper); color: var(--ink); font-size: 44px; }
.suits button.red { color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: #ffffff10; border-radius: 20px; padding: 8px 14px; font-weight: 600; }
.chip.on { background: var(--gold); color: #2a1d00; border-color: transparent; }
.seg { display: flex; background: #00000040; border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: #ffffff1c; color: var(--text); }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--gold); }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #111d; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 40; max-width: 88vw; text-align: center; font-size: 15px; backdrop-filter: blur(6px); }

@media (min-width: 700px) {
  body { background: #061a14; }
  .screen { max-width: 520px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .sheet-card { max-width: 520px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
