/* ===========================================================================
   1. STYLE D'ORIGINE — copié tel quel depuis belote_gsm.html (lignes 8 à 142).
   =========================================================================== */
:root {
  --card-w: 50px;
  --card-h: 56px;
  --stack-offset: 14px;
  --bg-table: radial-gradient(circle at center, #115e3b 0%, #062b1a 100%);
  --panel-bg: rgba(0, 0, 0, 0.25);
  --panel-border: rgba(255, 255, 255, 0.08);
  --gold: #fcd34d;
  --red-suit: #dc2626;
  --black-suit: #0f172a;
  --suit-spade: #1c2431;
  --suit-heart: #df2530;
  --suit-diamond: #1f7fe0;
  --suit-club: #159b53;
  --suit-spade-lt: #e2e8f0;
  --suit-heart-lt: #fca5a5;
  --suit-diamond-lt: #93c5fd;
  --suit-club-lt: #86efac;
  --text-main: #f8fafc;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-table); color: var(--text-main);
  display: flex; justify-content: center;
  padding: 20px 10px calc(20px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
}
#app { width: 100%; max-width: 800px; display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.score-board { display: flex; gap: 8px; background: var(--panel-bg); padding: 8px; border-radius: 12px; border: 1px solid var(--panel-border); }
.score { background: rgba(0,0,0,0.4); padding: 8px 16px; border-radius: 8px; font-size: 15px; }
.score b { color: var(--gold); font-size: 18px; margin-left: 6px; }
.pending-score { background: rgba(252,211,77,0.12); border: 1px solid rgba(252,211,77,0.35); }
button { font-family: inherit; transition: all 0.2s ease; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn { background: rgba(0,0,0,0.3); color: #fff; border: 1px solid var(--panel-border); cursor: pointer; padding: 8px 14px; border-radius: 8px; font-size: 14px; }
.btn:hover { background: rgba(255,255,255,0.15); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:disabled:hover { background: rgba(0,0,0,0.3); }
.count-badge { width: 36px; height: 36px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.3); border: 1px solid var(--panel-border); font-size: 16px; font-weight: 800; color: var(--gold); }
.btn-go { background: linear-gradient(135deg, var(--gold), #d97706); color: #451a03; font-weight: 700; padding: 10px 20px; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
.btn-go:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn-pass { background: #be123c; color: #fff; font-weight: 600; padding: 10px 24px; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
.btn-pass:hover { background: #e11d48; transform: translateY(-2px); }
.suitbtn { width: 52px; height: 52px; border-radius: 10px; font-size: 0; border: 2px solid rgba(255,255,255,0.25); cursor: pointer; box-shadow: 0 2px 5px rgba(0,0,0,0.35); }
.suitbtn:hover { transform: translateY(-3px); border-color: var(--gold); }
.suitbtn.s-spade { background: var(--suit-spade); }
.suitbtn.s-heart { background: var(--suit-heart); }
.suitbtn.s-diamond { background: var(--suit-diamond); }
.suitbtn.s-club { background: var(--suit-club); }
.panel { border-radius: 14px; padding: 8px; background: var(--panel-bg); border: 1px solid var(--panel-border); backdrop-filter: blur(8px); transition: all 0.3s ease; }
.panel.active { background: rgba(0, 0, 0, 0.4); border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold), inset 0 0 0 3px var(--gold), 0 0 14px 3px rgba(252, 211, 77, 0.45); }
.label { font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; opacity: 0.8; margin-bottom: 16px; }
.center { border-radius: 14px; padding: 8px; background: radial-gradient(circle, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.35) 100%); border: 1px solid rgba(0,0,0,0.5); box-shadow: inset 0 0 20px rgba(0,0,0,0.5); min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; overflow: hidden; }
.trickrow { display: flex; align-items: center; justify-content: center; gap: 48px; width: 100%; position: relative; }
.tcol { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tlab { font-size: 12px; opacity: 0.7; text-transform: uppercase; font-weight: 600; letter-spacing: 1px; }
.atout { width: 38px; height: 38px; border-radius: 999px; border: 2px solid rgba(255,255,255,0.7); box-shadow: 0 2px 6px rgba(0,0,0,0.5); }
.atout.s-spade { background: var(--suit-spade); }
.atout.s-heart { background: var(--suit-heart); }
.atout.s-diamond { background: var(--suit-diamond); }
.atout.s-club { background: var(--suit-club); }
.msg { text-align: center; font-size: 17px; font-weight: 600; min-height: 26px; color: var(--gold); letter-spacing: 0.5px; }
.card { width: var(--card-w); height: var(--card-h); border-radius: 7px; background: #2b3445; border: none; box-shadow: 0 2px 5px rgba(0,0,0,0.35); position: relative; flex: 0 0 auto; color: #fff; user-select: none; padding: 0; appearance: none; -webkit-appearance: none; display: flex; align-items: center; justify-content: center; transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease; }
.card.s-spade { background: var(--suit-spade); }
.card.s-heart { background: var(--suit-heart); }
.card.s-diamond { background: var(--suit-diamond); }
.card.s-club { background: var(--suit-club); }
.card .rank { font-weight: 800; font-size: 22px; color: #fff; line-height: 1; letter-spacing: 0.3px; }

@keyframes blink-jack { 0%, 100% { opacity: 1; box-shadow: 0 0 15px 5px var(--gold); } 50% { opacity: 0.3; box-shadow: none; } }
.forced-jack { animation: blink-jack 0.5s infinite; border: 2px solid var(--gold); }

@keyframes blink-winner { 0%, 100% { box-shadow: 0 2px 5px rgba(0,0,0,0.35); transform: scale(1); } 50% { box-shadow: 0 0 18px 6px var(--gold); transform: scale(1.09); } }
.trick-winner { animation: blink-winner 0.45s ease-in-out 3; outline: 2px solid var(--gold); outline-offset: 1px; z-index: 5; }

@keyframes bounce-down { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }
@keyframes bounce-up { 0%, 100% { transform: rotate(180deg) translateY(0); } 50% { transform: rotate(180deg) translateY(5px); } }
.turn-arrow { font-size: 32px; line-height: 1; color: var(--gold); text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.turn-arrow:not(.arrow-up) { animation: bounce-down 1s infinite; }
.turn-arrow.arrow-up { animation: bounce-up 1s infinite; }

.comp-bar { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 6px; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: 999px; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; }
.card.legal { box-shadow: 0 4px 10px rgba(0,0,0,0.5); cursor: pointer; }
.card.legal:hover { transform: translateY(-10px) scale(1.03); box-shadow: 0 12px 24px rgba(0,0,0,0.6); z-index: 10; }
.card.back { background: repeating-linear-gradient(45deg, #0d1320, #0d1320 5px, #18233a 5px, #18233a 10px); border: 1px solid #475569; }
.card.empty { background: transparent; border: 2px dashed rgba(255,255,255,0.2); box-shadow: none; }
.card-placeholder { width: var(--card-w); height: var(--card-h); }
.stack { position: relative; width: var(--card-w); height: calc(var(--card-h) + var(--stack-offset)); }
.stack .peek { position: absolute; top: 0; left: 0; transform: scale(0.85); transform-origin: top center; opacity: 0.8; filter: brightness(0.6); }
.stack .topcard { position: absolute; top: var(--stack-offset); left: 0; }
@keyframes slideToPlayer { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(180px) scale(0.3); opacity: 0; } }
@keyframes slideToComputer { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-180px) scale(0.3); opacity: 0; } }
.anim-win-player { animation: slideToPlayer 0.5s cubic-bezier(0.5, 0, 1, 1) 1.5s forwards; }
.anim-win-computer { animation: slideToComputer 0.5s cubic-bezier(0.5, 0, 1, 1) 1.5s forwards; }
.end { background: rgba(0,0,0,0.6); border-radius: 16px; padding: 24px; font-size: 15px; border: 1px solid var(--panel-border); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; margin: 16px 0; background: rgba(255,255,255,0.05); padding: 16px; border-radius: 12px; }
.win { font-size: 20px; font-weight: 800; color: var(--gold); margin-top: 16px; text-align: center; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal .box { background: var(--bg-table); border: 1px solid var(--gold); border-radius: 16px; padding: 24px; max-width: 380px; width: 100%; position: relative; box-shadow: 0 20px 40px rgba(0,0,0,0.5); max-height: 90vh; overflow-y: auto; }
.end-box { font-size: 15px; }
.modal .close { position: absolute; top: 12px; right: 12px; cursor: pointer; background: rgba(255,255,255,0.1); border: none; color: #fff; font-size: 16px; width: 32px; height: 32px; border-radius: 50%; }
.modal .close:hover { background: rgba(255,255,255,0.2); }
.computer-card-count { display: none; text-align: center; opacity: 0.85; margin-bottom: 10px; font-size: 13px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; } }
@media (max-width: 500px) {
  body { padding: 8px 4px; }
  #app { gap: 8px; }
  .comp-hand { display: none !important; }
  .computer-card-count { display: block; }
  :root { --card-w: 40px; --card-h: 46px; --stack-offset: 9px; }
  .card .rank { font-size: 17px; }
  .suitbtn { width: 44px; height: 44px; }
  .panel { padding: 6px; border-radius: 12px; }
  .center { padding: 6px; min-height: 62px; gap: 6px; }
  .trickrow { gap: 14px; }
  .msg { font-size: 14px; min-height: 22px; }
  .score { padding: 6px 10px; font-size: 13px; }
  .score b { font-size: 15px; }
  .btn { padding: 6px 10px; font-size: 12px; }
  .btn-pass { padding: 8px 16px; font-size: 14px; }
  .btn-go { padding: 8px 16px; font-size: 14px; }
  .label { margin-bottom: 8px; font-size: 11px; }
  .modal { padding: 10px; }
  .modal .box { padding: 16px; }
  .end-box { font-size: 13px; }
  .grid { gap: 6px 12px; padding: 12px; margin: 12px 0; }
  .win { font-size: 17px; }
}

/* ===========================================================================
   2. AJOUTS POUR LE JEU EN LIGNE (absents de l'original)
   =========================================================================== */

/* --- Écran « Qui joue ? » et chargement --- */
.home { width: 100%; max-width: 440px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.home h1 { text-align: center; color: var(--gold); font-size: 26px; margin: 8px 0 4px; }
.home .box { background: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.error { color: #fca5a5; font-weight: 600; text-align: center; }
.waiting { display: flex; align-items: center; gap: 10px; justify-content: center; opacity: 0.9; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.2); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Barre des scores (toujours visible pendant le jeu) --- */
.score { display: flex; align-items: center; gap: 4px; min-width: 0; }
.score .pname { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score.turn { box-shadow: inset 0 0 0 2px var(--gold); }
.header .deal-info { font-size: 13px; opacity: 0.75; }
.header-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.btn-small { padding: 5px 10px; font-size: 12px; }

/* --- Indication du tour, nom des joueurs dans les panneaux --- */
.pname-row { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 700; margin-bottom: 6px; opacity: 0.9; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; display: inline-block; }
.dot.off { background: #f87171; }
.turn-chip { background: var(--gold); color: #451a03; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.trump-label { font-size: 11px; opacity: 0.8; text-align: center; line-height: 1.3; }

/* --- Cartes non jouables grisées (quand c'est à moi de jouer) --- */
.card.dim { filter: brightness(0.42) saturate(0.75); }   /* opaque (la carte cachée dessous ne transparaît pas) et la couleur reste reconnaissable */
.hand-count { font-weight: 400; opacity: 0.8; }

/* --- Animation du pli gagné (mêmes animations que l'original, renommées moi/adversaire) --- */
.anim-win-me { animation: slideToPlayer 0.5s cubic-bezier(0.5, 0, 1, 1) 1.5s forwards; }
.anim-win-opp { animation: slideToComputer 0.5s cubic-bezier(0.5, 0, 1, 1) 1.5s forwards; }

/* --- Bandeaux : adversaire déconnecté, connexion perdue --- */
.banner { border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; text-align: center; }
.banner.warn { background: rgba(190, 18, 60, 0.85); }
.banner.info { background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(252,211,77,0.4); }
.msg.err { color: #fca5a5; }
.msg.ann { color: #fff; text-shadow: 0 0 12px var(--gold); font-size: 20px; }
.wait-note { text-align: center; opacity: 0.85; margin-top: 14px; }
#app.busy { cursor: progress; }

/* --- Saisie du code --- */
.code-label { font-size: 18px; font-weight: 700; color: var(--gold); }
.code-input { font: inherit; font-size: 26px; letter-spacing: 8px; text-align: center; padding: 10px 12px; width: 100%; max-width: 220px; margin: 0 auto;
  border-radius: 10px; border: 1px solid rgba(255,255,255,0.3); background: rgba(0,0,0,0.35); color: #fff; }
.code-input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

/* --- Barre d'options sous la table --- */
.footer-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 2px; }

/* --- Bandeau de proposition de nouvelle partie (au-dessus de tout, même des fenêtres) --- */
.toast-bar { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 160;
  width: min(560px, calc(100% - 24px)); background: #0b3a24; border: 1px solid var(--gold); border-radius: 14px;
  padding: 12px 14px; text-align: center; font-size: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.6); }

/* --- Fenêtres Bilan et Son --- */
.panel-title { font-weight: 700; font-size: 18px; margin-bottom: 14px; text-align: center; color: var(--gold); }
.bilan-grid { grid-template-columns: 1.3fr 1fr 1fr; align-items: center; text-align: center; }
.bilan-grid span { text-align: left; }
.bilan-grid .big { font-size: 22px; color: var(--gold); }
.bilan-note { text-align: center; font-size: 13px; opacity: 0.8; }
.history { max-height: 40vh; overflow-y: auto; border-radius: 10px; background: rgba(0,0,0,0.25); }
.history table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history th, .history td { padding: 6px 8px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.08); }
.history th { position: sticky; top: 0; background: #0b3a24; font-weight: 700; }
.history tr.ab td { opacity: 0.55; }
.res-win { color: #4ade80; font-weight: 700; }
.res-loss { color: #f87171; font-weight: 700; }
.res-ab { font-style: italic; }
.opt { display: flex; align-items: center; gap: 10px; margin: 10px 0 6px; font-size: 15px; cursor: pointer; }
.opt input[type=checkbox] { width: 20px; height: 20px; accent-color: #d97706; }
#son-vol { width: 100%; accent-color: #d97706; }

@media (max-width: 500px) {
  :root { --card-w: 38px; --card-h: 46px; }
  .hand-row { gap: 4px !important; }
  .stack-row { gap: 6px !important; }
  .score { padding: 6px 8px; }
  .score .pname { max-width: 6.5em; }
  .home h1 { font-size: 22px; }
}
