/* Connexion : une main rejouée sur le tapis à côté du formulaire.
   Les équités affichées sont calculées par poker-odds.js au chargement. */
#authScreen { --felt:var(--felt-grain,none),radial-gradient(120% 90% at 50% 35%,#8a2232 0%,#5a1220 48%,#34090f 100%); --felt-rail:#2a070c; --gain:#7be3a8; --ivory:#f6efec; --muted:#c6babc; --ease-out:cubic-bezier(.16,1,.3,1); position:relative; overflow:hidden; overflow:clip; isolation:isolate; }
#authScreen::before { content:''; position:absolute; inset:-20%; z-index:-1; background:radial-gradient(40% 35% at 30% 40%,#5a122033 0%,transparent 70%),radial-gradient(35% 30% at 75% 70%,#8a223222 0%,transparent 70%); animation:auth-drift 22s ease-in-out infinite alternate; pointer-events:none; }
@keyframes auth-drift { to { transform:translate3d(4%,-3%,0) rotate(4deg); } }

#authScreen .auth-card { position:relative; z-index:1; animation:auth-card-in .9s var(--ease-out) both; }
@keyframes auth-card-in { from { opacity:0; transform:translateY(14px); filter:blur(6px); } }

.auth-stage { display:none; }

@media (min-width:1040px) {
  #authScreen { grid-template-columns:minmax(420px,600px) 448px; justify-content:center; align-items:center; gap:clamp(48px,6vw,96px); padding:48px clamp(32px,5vw,72px); }
  .auth-stage { display:grid; gap:24px; align-content:center; justify-self:stretch; width:100%; min-width:0; animation:auth-card-in 1.1s var(--ease-out) .12s both; }
  /* La main tient toujours dans la hauteur de l'écran et reste à l'écran quand on fait défiler le formulaire :
     colonne collante, tapis dimensionné sur la hauteur (titre 148 + écarts 72 + récit 122 + barre 52 + places des joueurs 56 + marges 96 ≈ 546 px, plus 0,74 × largeur). */
  .auth-stage { position:sticky; top:48px; align-self:start; min-height:calc(100svh - 96px); }
  .auth-stage .st-table { width:min(calc(100% - 30px), max(320px, calc((100svh - 546px) * 1.34))); margin-inline:auto; }
}
/* Écran d'ordinateur peu haut (portable 1280 × 720…) : sans la phrase d'accroche, le tapis garde une bonne taille. */
@media (min-width:1040px) and (max-height:840px) {
  .st-lead { display:none; }
  .auth-stage .st-table { width:min(calc(100% - 30px), max(320px, calc((100svh - 484px) * 1.34))); }
}
/* Encore moins haut (portable 1280 × 720) : sans titre, la main et sa barre restent entières. */
@media (min-width:1040px) and (max-height:760px) {
  .auth-stage .st-head { display:none; }
  .auth-stage .st-table { width:min(calc(100% - 30px), max(320px, calc((100svh - 374px) * 1.34))); }
}

.st-head { display:grid; gap:12px; max-width:560px; }
.st-title { margin:0; color:var(--ivory); font:650 clamp(34px,3.2vw,46px)/1.06 var(--font-display); letter-spacing:-.035em; text-wrap:balance; max-width:15ch; }
.st-lead { margin:0; color:var(--muted); font:400 16px/1.55 var(--font-display); max-width:44ch; }

/* Tapis */
/* Le tapis ne porte que le tableau et le pot : chaque joueur a sa propre place réservée au-dessus et au-dessous
   (hauteur d'une carte + étiquette), son étiquette posée sur le bord. Rien ne se chevauche, quelle que soit la largeur. */
.st-table { --seat:calc(var(--cw,50px) * 1.4 + 34px); position:relative; aspect-ratio:2/1; border-radius:999px; background:var(--felt); box-shadow:0 0 0 14px var(--felt-rail),0 0 0 15px #ffffff14,0 40px 80px -40px #000; margin:calc(var(--seat) - 6px) 15px calc(var(--seat) - 6px); overflow:visible; }
.st-table::after { content:''; position:absolute; inset:0; border-radius:inherit; background:radial-gradient(45% 35% at var(--lx,40%) var(--ly,30%),#ffffff12,transparent 70%); animation:st-light 14s ease-in-out infinite alternate; pointer-events:none; }
@keyframes st-light { from { --lx:32%; --ly:28%; } to { --lx:66%; --ly:44%; } }
@property --lx { syntax:'<percentage>'; inherits:false; initial-value:40%; }
@property --ly { syntax:'<percentage>'; inherits:false; initial-value:30%; }

.st-deck { position:absolute; left:50%; top:50%; width:1px; height:1px; }
.st-seat { position:absolute; left:50%; display:grid; justify-items:center; gap:8px; transform:translateX(-50%); }
.st-seat--villain { bottom:calc(100% - 6px); }
.st-seat--hero { top:calc(100% - 6px); }
.st-seat__hand { display:flex; gap:6px; }
.st-seat__tag { display:flex; align-items:center; gap:8px; padding:5px 12px; border-radius:999px; background:#140a0dcc; border:1px solid #ffffff14; color:var(--ivory); font:600 12px/1.2 var(--font-display); white-space:nowrap; box-shadow:0 6px 14px -12px #000; transition:border-color .5s var(--ease-out),box-shadow .5s var(--ease-out); }
.st-seat__tag b { font-weight:600; color:var(--muted); font-variant-numeric:tabular-nums; }
.st-seat.is-winner .st-seat__tag { border-color:#7be3a866; box-shadow:0 8px 22px -12px #7be3a8aa; }
.st-seat.is-winner .st-seat__tag b { color:var(--gain); }

.st-board { position:absolute; left:50%; top:50%; display:flex; gap:7px; transform:translate(-50%,-62%); }
.st-slot { width:var(--cw); aspect-ratio:5/7; border-radius:7px; border:1px dashed #ffffff1f; }

.st-pot { position:absolute; left:50%; top:50%; display:flex; align-items:center; gap:8px; transform:translate(-50%,calc(var(--cw) * .9)); color:var(--ivory); font:600 13px/1 var(--font-display); font-variant-numeric:tabular-nums; }
.st-chips { position:relative; width:20px; height:16px; }
.st-chips i { position:absolute; left:0; width:20px; height:6px; border-radius:50%; background:#e74953; box-shadow:inset 0 0 0 2px #fff6, 0 1px 0 #3a0b12; transition:transform .5s var(--ease-out); }
.st-chips i:nth-child(1) { bottom:0; } .st-chips i:nth-child(2) { bottom:4px; background:#f6efec; } .st-chips i:nth-child(3) { bottom:8px; }
.st-pot.is-bump .st-chips i:nth-child(3) { transform:translateY(-3px); }
.st-pot.is-gone { opacity:0; transform:translate(-50%,calc(var(--cw) * 2.2)) scale(.8); transition:opacity .6s var(--ease-out),transform .8s var(--ease-out); }

/* Cartes */
.st-card { --fx:0px; --fy:-160px; position:relative; width:var(--cw); aspect-ratio:5/7; perspective:600px; opacity:0; transform:translate(var(--fx),var(--fy)) rotate(-14deg) scale(.86); transition:transform .75s var(--ease-out),opacity .35s ease-out; }
.st-card.is-in { opacity:1; transform:none; }
.st-card.is-win { transform:translateY(-8px); }
.st-card.is-dim { opacity:.42; }
.st-card.is-out { opacity:0; transform:translateY(26px) scale(.9); transition:transform .6s var(--ease-out),opacity .45s ease-out; }
.st-card__inner { position:absolute; inset:0; transform-style:preserve-3d; transform:rotateY(180deg); transition:transform .65s var(--ease-out) .28s; }
.st-card.is-up .st-card__inner { transform:none; }
.st-face,.st-back { position:absolute; inset:0; border-radius:7px; backface-visibility:hidden; }
.st-face { display:grid; place-items:center; align-content:center; gap:1px; background:linear-gradient(165deg,#fffaf7,#efe4de); color:#1d1214; box-shadow:0 1px 0 #fff inset,0 8px 16px -8px #000c; font:700 calc(var(--cw) * .4)/1 var(--font-display); letter-spacing:-.02em; }
.st-face span:last-child { font-size:calc(var(--cw) * .36); }
.st-face.is-red { color:#b8202f; }
.st-card.is-win .st-face { box-shadow:0 0 0 2px #7be3a8,0 12px 22px -10px #000; }
.st-back { transform:rotateY(180deg); background:repeating-linear-gradient(45deg,#8a2232 0 4px,#6d1a28 4px 8px); box-shadow:inset 0 0 0 3px #f6efec,inset 0 0 0 4px #5a1220,0 8px 16px -8px #000c; }

/* Récit et équité */
.st-log { display:grid; gap:14px; min-height:104px; margin-top:18px; }
.st-line { display:flex; align-items:baseline; gap:12px; margin:0; color:var(--ivory); font:500 15px/1.45 var(--font-display); min-height:22px; }
.st-street { flex:none; min-width:58px; color:#e74953; font-weight:650; }
.st-text { transition:opacity .35s ease-out,transform .5s var(--ease-out); }
.st-line.is-swap .st-street,.st-line.is-swap .st-text { opacity:0; transform:translateY(6px); }
.st-street { transition:opacity .35s ease-out,transform .5s var(--ease-out); }
.st-eq { display:grid; grid-template-columns:44px minmax(0,1fr) 56px; align-items:center; gap:6px 12px; color:var(--muted); font:500 13px/1 var(--font-display); }
.st-eq output { color:var(--ivory); font-weight:600; text-align:right; font-variant-numeric:tabular-nums; }
.st-bar { height:6px; border-radius:999px; background:#ffffff12; overflow:hidden; }
.st-bar i { display:block; height:100%; width:var(--w,0%); border-radius:inherit; background:var(--gain); transition:width .9s var(--ease-out); }
.st-bar--villain i { background:#c9b5b8; }

/* Téléphone et tablette : la table au-dessus du formulaire, sans titre. */
@media (max-width:1039px) {
  #authScreen { align-content:start; gap:18px; }
  .auth-stage.is-compact { display:grid; width:min(400px,100%); justify-self:center; gap:12px; padding-top:4px; }
  .auth-stage.is-compact .st-head { display:none; }
  .auth-stage.is-compact .st-table { --seat:calc(var(--cw) * 1.4 + 30px); margin:calc(var(--seat) - 6px) 12px calc(var(--seat) - 6px); box-shadow:0 0 0 10px var(--felt-rail),0 0 0 11px #ffffff14,0 30px 60px -36px #000; }
  .auth-stage.is-compact .st-log { min-height:0; gap:10px; margin-top:10px; }
  .auth-stage.is-compact .st-eq { display:none; }
  .auth-stage.is-compact .st-line { justify-content:center; gap:10px; }
  .auth-stage.is-compact .st-street { min-width:0; }
  .auth-stage.is-compact .st-line { font-size:13px; }
  .auth-stage.is-compact .st-seat__tag { padding:4px 10px; }
}

/* Très petits écrans (iPhone SE…) : sans la phrase du coup, le bouton « Essayer sans compte » reste dans le premier écran. */
@media (max-width:1039px) and (max-height:640px) { .auth-stage.is-compact .st-log { display:none; } }

/* Ordre : la main est après le formulaire dans le code, la grille la remet à gauche (ordinateur) ou au-dessus (téléphone). */
@media (min-width:1040px) { #authScreen .auth-stage { grid-column:1; grid-row:1; } #authScreen > .auth-card { grid-column:2; grid-row:1; } }
@media (max-width:1039px) { #authScreen .auth-stage.is-compact { order:-1; } }
/* Barre « Parcourir la main » sous le récit ; cartes inspectables ; pose instantanée quand on recule */
.st-controls { margin-top:4px; }
.auth-stage.is-compact .st-controls { margin-top:0; }
.st-card[data-inspect] { cursor:help; }
@media (hover:hover) { .st-card.is-in:hover { translate:0 -4px; } .st-card { transition:transform .75s var(--ease-out),opacity .35s ease-out,translate .25s var(--ease-out); } }
.st-card.is-instant, .st-card.is-instant .st-card__inner { transition:none !important; }
@media (max-width:1039px) and (max-height:640px) { .auth-stage.is-compact .st-controls { display:none; } }

@media (prefers-reduced-motion:reduce) {
  #authScreen::before,.st-table::after,#authScreen .auth-card,.auth-stage { animation:none; }
  .st-card,.st-card__inner,.st-bar i,.st-text,.st-street,.st-pot.is-gone { transition:none; }
}
