
/* v1.12.1O — rifiniture mobile + preferenze multiplayer per giocatore */

/* Sfide: ogni giocatore sceglie il proprio mazzo e tavolo. */
.friend-accept-config{display:grid;grid-template-columns:minmax(120px,1fr) minmax(120px,1fr) auto;gap:8px;align-items:end}
.friend-accept-config label{display:grid;gap:4px}
.friend-accept-config label small{color:#b9c9c1;font-size:.68rem;font-weight:800}
.friend-accept-config select{min-height:38px;padding:7px 9px;border-radius:9px;border:1px solid rgba(216,166,60,.3);background:#111b17;color:#f4ead5;font:inherit;font-size:.82rem}
.friend-incoming-config{align-items:center}
.friend-accept-actions{align-items:end}
.mobile-phase-label{display:none}

@media(max-width:820px){
  /* La barra alta deve restare leggibile anche sui telefoni: la vecchia
     media query globale nascondeva .game-nav-center sotto i 980px. */
  .game-nav.game-nav-center-only{
    display:flex!important;
    min-height:46px!important;
    height:46px!important;
    padding:0 8px!important;
    align-items:center!important;
    justify-content:center!important;
    overflow:visible!important;
    position:relative!important;
    z-index:200!important;
  }
  .game-nav.game-nav-center-only .game-nav-center{
    display:block!important;
    position:static!important;
    transform:none!important;
    width:auto!important;
    max-width:94vw!important;
    margin:0 auto!important;
    text-align:center!important;
    font-size:.82rem!important;
    line-height:1.1!important;
    color:#f4ead5!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
  .tournament-phase-label{font-weight:900;color:#f0d17b;letter-spacing:.01em}
  .desktop-phase-label{display:none!important}
  .mobile-phase-label{display:inline!important}

  /* Il proprio nome non deve più stare sopra le carte. Su mobile basta
     l'avatar + "Tu": il nome completo è già noto all'utente. */
  .player-zone > .player-identity:not(.bot-identity){
    left:10px!important;
    right:auto!important;
    bottom:max(48px,calc(env(safe-area-inset-bottom) + 46px))!important;
    width:54px!important;
    max-width:54px!important;
    min-height:36px!important;
    padding:0!important;
    gap:3px!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    text-align:center!important;
    z-index:35!important;
  }
  .player-zone > .player-identity:not(.bot-identity) .identity-title,
  .player-zone > .player-identity:not(.bot-identity) .dealer-name-mark{
    display:block!important;
    text-align:center!important;
  }
  .player-zone > .player-identity:not(.bot-identity) b,
  .player-zone > .player-identity:not(.bot-identity) .dealer-mini-deck,
  .player-zone > .player-identity:not(.bot-identity) .live-match-score{
    display:none!important;
  }
  .player-zone > .player-identity:not(.bot-identity) small{
    display:block!important;
    margin:1px 0 0!important;
    font-size:.62rem!important;
    line-height:1!important;
    color:#d9e0dc!important;
  }

  /* Ultima presa: invece di centrarla rispetto a un antenato trasformato,
     la ancoriamo dentro il viewport e la rendiamo scrollabile se necessario. */
  .last-capture-anchor.open .last-capture-popover,
  .last-capture-anchor.has-last-capture.open .last-capture-popover{
    position:fixed!important;
    left:50%!important;
    right:auto!important;
    top:max(10px,env(safe-area-inset-top))!important;
    bottom:auto!important;
    width:min(360px,calc(100vw - 20px))!important;
    max-height:calc(100dvh - 20px)!important;
    overflow:auto!important;
    transform:translateX(-50%)!important;
    transform-origin:center top!important;
    opacity:1!important;
    visibility:visible!important;
    pointer-events:auto!important;
    z-index:10020!important;
  }
  .last-capture-anchor.open:before{
    z-index:10010!important;
  }
  .last-capture-row{align-items:start!important}
  .last-capture-hint{font-size:.7rem!important;line-height:1.25!important}

  /* Buona: toast nel tavolo, appena fuori dalle mani. */
  .player-zone .accusation-badge.player-accusation{
    position:absolute!important;
    left:50%!important;
    top:-42px!important;
    bottom:auto!important;
    transform:translateX(-50%)!important;
    margin:0!important;
    z-index:72!important;
    max-width:80vw!important;
  }
  .bot-zone .accusation-badge.bot-accusation{
    position:absolute!important;
    left:50%!important;
    top:auto!important;
    bottom:-38px!important;
    transform:translateX(-50%)!important;
    margin:0!important;
    z-index:72!important;
    width:max-content!important;
    max-width:80vw!important;
  }

  /* Riepilogo: l'overlay stesso scorre. Così né intestazione né bottoni
     possono finire fuori dal viewport su iPhone SE e telefoni bassi. */
  .round-summary-overlay{
    position:fixed!important;
    inset:0!important;
    display:block!important;
    padding:max(6px,env(safe-area-inset-top)) 6px max(6px,env(safe-area-inset-bottom))!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    z-index:10050!important;
  }
  .round-summary{
    width:min(100%,460px)!important;
    max-width:calc(100vw - 12px)!important;
    max-height:none!important;
    min-height:0!important;
    margin:0 auto!important;
    padding:12px 10px 10px!important;
    overflow:visible!important;
  }
  .round-summary h2{font-size:clamp(1.55rem,8vw,2.15rem)!important}
  .summary-actions{padding-bottom:3px!important}

  .friend-accept-config{
    grid-template-columns:1fr 1fr!important;
    width:100%;
  }
  .friend-accept-config .accept{grid-column:1/-1}
  .friend-accept-actions{width:100%;align-items:stretch!important}
  .friend-incoming-config{align-items:stretch!important}
}

@media(max-width:390px) and (max-height:720px){
  .game-nav.game-nav-center-only .game-nav-center{font-size:.76rem!important}
  .last-capture-anchor.open .last-capture-popover,
  .last-capture-anchor.has-last-capture.open .last-capture-popover{
    width:calc(100vw - 12px)!important;
    top:6px!important;
    max-height:calc(100dvh - 12px)!important;
  }
  .last-capture-popover{padding:14px!important}
  .last-capture-played img,.last-capture-taken img{width:39px!important;max-height:59px!important}
  .player-zone .accusation-badge.player-accusation{top:-34px!important;padding:5px 9px!important}
  .bot-zone .accusation-badge.bot-accusation{bottom:-31px!important;padding:5px 9px!important}
  .round-summary{padding:8px 7px 8px!important}
  .summary-kicker{font-size:.56rem!important}
  .round-summary h2{font-size:1.42rem!important;line-height:1!important}
  .summary-subtitle{font-size:.68rem!important;margin:4px 0 6px!important}
  .summary-row,.summary-row-with-cards{min-height:36px!important}
  .summary-actions{gap:5px!important;margin-top:7px!important}
  .summary-button{min-height:36px!important;padding:7px 10px!important}
}


/* v1.12.1O1 — seconda rifinitura mobile tavolo */
.mobile-player-score-chip{display:none}
.last-capture-initial>small{display:block;margin-bottom:8px;color:#b8c9c1;font-weight:800}
.last-capture-initial>div{display:flex;gap:5px;flex-wrap:wrap}
.last-capture-initial img{width:48px;max-height:72px;border-radius:5px;box-shadow:0 5px 12px #0008}

@media(max-width:820px){
  /* Profilo umano: sul telefono resta davvero solo il cerchio/avatar. */
  .player-zone > .player-identity:not(.bot-identity){
    width:42px!important;max-width:42px!important;min-width:42px!important;
    min-height:42px!important;height:42px!important;
    left:10px!important;bottom:54px!important;
    display:block!important;padding:0!important;background:transparent!important;
  }
  .player-zone > .player-identity:not(.bot-identity) > div{display:none!important}
  .player-zone > .player-identity:not(.bot-identity) .avatar{
    width:42px!important;height:42px!important;min-width:42px!important;margin:0!important;
  }

  /* Punteggio partita dell'umano: chip indipendente dalle carte. */
  .mobile-player-score-chip{
    display:flex!important;position:absolute!important;left:62px!important;top:8px!important;
    z-index:88!important;align-items:center!important;gap:5px!important;
    min-height:30px!important;padding:4px 8px!important;border-radius:999px!important;
    background:linear-gradient(145deg,#e4bd65,#9f6f17)!important;color:#171108!important;
    border:1px solid #f2d88c!important;box-shadow:0 5px 14px #0008!important;
    font-size:.67rem!important;font-weight:900!important;line-height:1!important;
  }
  .mobile-player-score-chip strong{font-size:1rem!important}

  /* Buone: mini badge ai margini della zona giocatore, mai sopra la mano. */
  .player-zone .accusation-badge.player-accusation{
    left:8px!important;top:44px!important;right:auto!important;bottom:auto!important;
    transform:none!important;padding:4px 7px!important;max-width:110px!important;
    font-size:.62rem!important;z-index:84!important;
  }
  .bot-zone .accusation-badge.bot-accusation{
    left:8px!important;right:auto!important;top:auto!important;bottom:7px!important;
    transform:none!important;padding:4px 7px!important;max-width:110px!important;
    font-size:.62rem!important;z-index:84!important;
  }
  .player-zone .accusation-badge strong,.bot-zone .accusation-badge strong{font-size:.66rem!important}

  /* Le scope dell'avversario devono stare sopra mano/mazzetto e restare leggibili. */
  .bot-zone .take-area,.bot-zone .bot-take-area{z-index:96!important}
  .bot-zone .scope-marker,.bot-zone .bot-scope-marker,.bot-zone .scope-count-only{z-index:98!important}
  .last-capture-anchor.open + .scope-marker,
  .last-capture-anchor.open + .scope-count-only{opacity:0!important;visibility:hidden!important;pointer-events:none!important}

  /* Popup ultima presa: un po' più in basso e nessun elemento del tavolo può passarci sopra. */
  .last-capture-anchor.open .last-capture-popover,
  .last-capture-anchor.has-last-capture.open .last-capture-popover{
    top:max(52px,calc(env(safe-area-inset-top) + 46px))!important;
    max-height:calc(100dvh - 62px - env(safe-area-inset-bottom))!important;
    z-index:30000!important;
  }
  .last-capture-anchor.open:before{z-index:29990!important}
  .last-capture-initial img{width:42px!important;max-height:64px!important}
}

@media(max-width:390px) and (max-height:720px){
  .mobile-player-score-chip{left:58px!important;top:5px!important;padding:3px 7px!important}
  .player-zone .accusation-badge.player-accusation{top:39px!important}
  .bot-zone .accusation-badge.bot-accusation{bottom:4px!important}
  .last-capture-anchor.open .last-capture-popover,
  .last-capture-anchor.has-last-capture.open .last-capture-popover{
    top:48px!important;max-height:calc(100dvh - 54px)!important;
  }
}


/* v1.12.1P — UX sfide, punteggio mobile e sorteggio desktop */

/* Sfide ricevute: separa bene riepilogo, preferenze e azioni. */
.friend-incoming-config{
  display:grid!important;
  grid-template-columns:minmax(180px,.85fr) minmax(360px,1.6fr)!important;
  gap:16px!important;
  align-items:center!important;
  padding:14px!important;
}
.friend-incoming-config>.friend-actions{
  display:grid!important;
  grid-template-columns:minmax(0,1fr) auto!important;
  gap:10px!important;
  align-items:end!important;
}
.friend-incoming-config .friend-accept-config{
  grid-template-columns:minmax(130px,1fr) minmax(130px,1fr) auto!important;
  gap:10px!important;
}
.friend-incoming-config .friend-accept-config .accept{
  min-height:38px!important;
  white-space:nowrap!important;
}
.friend-incoming-config .decline{
  min-height:38px!important;
  white-space:nowrap!important;
}

/* Sorteggio PC: le 40 carte vengono disposte in due righe ordinate. */
@media(min-width:821px){
  .draw-panel .draw-cards{
    width:min(1320px,96vw)!important;
    display:grid!important;
    grid-template-columns:repeat(20,minmax(0,58px))!important;
    justify-content:center!important;
    align-items:center!important;
    gap:8px 4px!important;
    margin:8px auto 10px!important;
    padding:8px!important;
    overflow:visible!important;
  }
  .draw-panel .draw-choice{
    width:58px!important;
    height:88px!important;
    min-width:0!important;
    margin:0!important;
    flex:none!important;
  }
  .draw-panel .draw-choice:hover,
  .draw-panel .draw-choice:focus-visible{
    transform:translateY(-8px) scale(1.08)!important;
  }
}

/* Multiplayer: popup di conferma abbandono. */
.multiplayer-confirm-abandon{
  position:fixed;inset:0;z-index:40000;display:none;place-items:center;
  padding:18px;background:rgba(3,8,6,.72);backdrop-filter:blur(7px)
}
.multiplayer-confirm-abandon.show{display:grid}
.multiplayer-confirm-card{
  width:min(470px,94vw);padding:28px;border-radius:22px;
  border:1px solid rgba(227,183,75,.42);
  background:linear-gradient(145deg,#16251e,#0d1713);
  box-shadow:0 28px 80px #000b;text-align:center;color:#f5ead5
}
.multiplayer-confirm-card .confirm-icon{
  width:58px;height:58px;margin:0 auto 12px;border-radius:50%;
  display:grid;place-items:center;background:#9f2f29;color:#fff;font-size:2rem;font-weight:900
}
.multiplayer-confirm-card h3{margin:4px 0 10px;font-size:1.55rem;color:#f3d57d}
.multiplayer-confirm-card p{margin:0;color:#c7d1cc;line-height:1.6}
.multiplayer-confirm-actions{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:22px}
.multiplayer-confirm-actions button{min-height:44px;border:0;border-radius:12px;font-weight:900;cursor:pointer}
.multiplayer-confirm-cancel{background:#245b3b;color:#fff}
.multiplayer-confirm-danger{background:#922c27;color:#fff}

/* Mobile: avatar umano più piccolo e punteggio immediatamente sotto. */
@media(max-width:820px){
  .player-zone > .player-identity:not(.bot-identity){
    width:34px!important;max-width:34px!important;min-width:34px!important;
    min-height:34px!important;height:34px!important;
    left:10px!important;bottom:57px!important;
  }
  .player-zone > .player-identity:not(.bot-identity) .avatar{
    width:34px!important;height:34px!important;min-width:34px!important;
    font-size:.86rem!important;
  }
  .mobile-player-score-chip{
    left:10px!important;right:auto!important;top:auto!important;bottom:19px!important;
    min-width:34px!important;min-height:24px!important;
    padding:3px 6px!important;border-radius:999px!important;
    justify-content:center!important;gap:3px!important;
    font-size:.55rem!important;line-height:1!important;
    z-index:92!important;
  }
  .mobile-player-score-chip strong{font-size:.78rem!important}

  .friend-incoming-config{
    grid-template-columns:1fr!important;
    gap:12px!important;
  }
  .friend-incoming-config>.friend-actions{
    grid-template-columns:1fr!important;
    gap:8px!important;
  }
  .friend-incoming-config .friend-accept-config{
    grid-template-columns:1fr 1fr!important;
  }
  .friend-incoming-config .friend-accept-config .accept{grid-column:1/-1!important}
  .multiplayer-confirm-actions{grid-template-columns:1fr!important}
}

@media(max-width:390px) and (max-height:720px){
  .player-zone > .player-identity:not(.bot-identity){bottom:55px!important}
  .mobile-player-score-chip{left:10px!important;bottom:18px!important;top:auto!important}
}

/* v1.12.1Q — profilo umano mobile minimo + punteggio sotto avatar */
@media(max-width:820px){
  .player-zone > .player-identity:not(.bot-identity) > div{display:none!important}
  .player-zone > .player-identity:not(.bot-identity){
    width:32px!important;min-width:32px!important;max-width:32px!important;height:32px!important;min-height:32px!important;
    left:10px!important;bottom:60px!important;padding:0!important;background:transparent!important;border:0!important;box-shadow:none!important
  }
  .player-zone > .player-identity:not(.bot-identity) .avatar{
    width:32px!important;height:32px!important;min-width:32px!important;font-size:.8rem!important;border-width:0!important
  }
  .mobile-player-score-chip{
    left:10px!important;top:auto!important;bottom:24px!important;right:auto!important;
    min-width:32px!important;min-height:22px!important;padding:2px 5px!important;border-radius:999px!important;
    font-size:0!important;line-height:1!important;z-index:95!important
  }
  .mobile-player-score-chip strong{font-size:.72rem!important;line-height:1!important}
  .multiplayer-classic-layout .player-zone > .player-identity:not(.bot-identity) > div{display:none!important}
}


/* v1.12.1Q1 — popup partita persistente in Home */
.active-game-resume-overlay{position:fixed;inset:0;z-index:60000;display:grid;place-items:center;padding:20px;background:rgba(3,9,6,.76);backdrop-filter:blur(9px)}
.active-game-resume-card{width:min(610px,94vw);max-height:92vh;overflow:auto;padding:30px;border:1px solid rgba(222,177,64,.5);border-radius:24px;background:linear-gradient(145deg,#13261d,#09140f);box-shadow:0 32px 100px #000c;color:#f4ead6}
.active-game-resume-kicker{display:block;color:#e7bf59;font-size:.75rem;font-weight:900;letter-spacing:.13em;text-align:center}.active-game-resume-card h2{margin:8px 0 22px;text-align:center;font-size:clamp(1.65rem,4vw,2.35rem);color:#f4d780}.active-game-resume-details{display:grid;grid-template-columns:1fr 1fr;gap:10px}.active-game-resume-details>div{padding:13px 14px;border:1px solid #e1b84b25;border-radius:14px;background:#ffffff07;display:flex;flex-direction:column;gap:3px}.active-game-resume-details span{font-size:.7rem;text-transform:uppercase;letter-spacing:.08em;color:#8fa69a;font-weight:800}.active-game-resume-details strong{font-size:1rem;color:#f4ead6}.active-game-resume-details small{font-size:.78rem;color:#a9b9b1}.active-game-resume-warning{margin:16px 0 0;padding:15px 16px;border-radius:14px;background:#7d2e251f;border:1px solid #b74b3c55;color:#d6c7bd;line-height:1.55}.active-game-resume-warning strong{color:#ffd889}.active-game-resume-actions{display:grid;grid-template-columns:1.2fr 1fr;gap:10px;margin-top:18px}.active-game-resume-actions a,.active-game-resume-actions button{width:100%;min-height:48px;border:0;border-radius:13px;display:flex;align-items:center;justify-content:center;font-weight:900;text-decoration:none;cursor:pointer}.active-game-resume-continue{background:#2d7048;color:#fff!important}.active-game-resume-abandon{background:#922d28;color:#fff}.active-game-resume-actions form{margin:0}
@media(max-width:620px){.active-game-resume-overlay{padding:12px}.active-game-resume-card{padding:22px 16px;border-radius:20px}.active-game-resume-details{grid-template-columns:1fr}.active-game-resume-actions{grid-template-columns:1fr}.active-game-resume-card h2{margin-bottom:16px}}

/* v1.12.1Q7 — sfide ricevute: layout pulito, azioni leggibili, modalità dedicata */
.friend-inbox-grid.incoming-only{
  grid-template-columns:minmax(0,860px)!important;
  justify-content:center!important;
  max-width:920px!important;
  margin-left:auto!important;
  margin-right:auto!important;
}
.friend-inbox-grid.incoming-only>.friend-card{width:100%!important}
.friend-incoming-config{
  display:grid!important;
  grid-template-columns:minmax(150px,.7fr) minmax(0,1.65fr)!important;
  gap:18px!important;
  align-items:center!important;
  padding:16px!important;
}
.friend-incoming-player{min-width:0}
.friend-incoming-player strong{font-size:1rem;color:#f7ead0}
.friend-incoming-player strong small{margin-left:4px;color:#f1cc69}
.friend-incoming-player span{margin-top:5px!important;color:#aabdb4!important;font-size:.78rem!important}
.friend-accept-actions{
  display:grid!important;
  grid-template-columns:minmax(0,1fr) auto!important;
  gap:10px!important;
  align-items:end!important;
  width:100%!important;
}
.friend-accept-config{
  display:grid!important;
  grid-template-columns:minmax(120px,1fr) minmax(120px,1fr) minmax(150px,auto)!important;
  gap:10px!important;
  align-items:end!important;
  min-width:0!important;
}
.friend-accept-config label{min-width:0}
.friend-accept-config select{
  width:100%!important;
  min-height:42px!important;
  border-radius:12px!important;
  border:1px solid rgba(231,190,84,.45)!important;
  background:#0d1c16!important;
  color:#f7ead0!important;
  padding:8px 11px!important;
}
.friend-choice-accept,.friend-choice-decline{
  min-height:42px!important;
  border-radius:12px!important;
  padding:9px 16px!important;
  font-weight:950!important;
  letter-spacing:.01em!important;
  white-space:nowrap!important;
  box-shadow:0 7px 18px rgba(0,0,0,.18)!important;
  transition:transform .16s ease,filter .16s ease!important;
}
.friend-choice-accept{
  background:linear-gradient(135deg,#2f9a64,#1f7049)!important;
  border:1px solid #77c99b!important;
  color:white!important;
}
.friend-choice-decline{
  background:linear-gradient(135deg,#a23a34,#762723)!important;
  border:1px solid #d2716a!important;
  color:#fff5f3!important;
}
.friend-choice-accept:hover,.friend-choice-decline:hover{transform:translateY(-1px);filter:brightness(1.06)}
.friend-reject-form{margin:0!important}
.friend-home-alert-declined{border-color:rgba(213,103,91,.72)!important;background:linear-gradient(135deg,#34201d,#201411)!important}
.friend-home-alert-declined .friend-home-alert-icon{background:#a33b34!important;color:#fff!important}

@media(max-width:900px){
  .friend-incoming-config{grid-template-columns:1fr!important;gap:12px!important}
  .friend-accept-actions{grid-template-columns:1fr!important}
  .friend-accept-config{grid-template-columns:1fr 1fr!important}
  .friend-choice-accept{grid-column:1/-1!important;width:100%!important}
  .friend-choice-decline{width:100%!important}
}

@media(max-width:520px){
  .friend-accept-config{grid-template-columns:1fr!important}
  .friend-choice-accept{grid-column:auto!important}
  .friend-challenge-row{padding:13px!important}
}

/* v1.12.1Q8 — sfida ricevuta: più respiro e nessuna sovrapposizione */
.friend-inbox-grid.incoming-only{grid-template-columns:minmax(0,1080px)!important;max-width:1140px!important}
.friend-incoming-config{grid-template-columns:minmax(170px,.65fr) minmax(620px,2.35fr)!important;gap:28px!important;padding:20px 22px!important}
.friend-accept-actions{grid-template-columns:minmax(0,1fr) minmax(128px,auto)!important;gap:16px!important}
.friend-accept-config{grid-template-columns:minmax(150px,1fr) minmax(170px,1fr) minmax(190px,auto)!important;gap:14px!important}
.friend-choice-accept,.friend-choice-decline{min-height:46px!important;padding:10px 20px!important}
.friend-choice-decline{min-width:128px!important}
@media(max-width:1050px){
 .friend-incoming-config{grid-template-columns:1fr!important;gap:14px!important}
 .friend-accept-actions{grid-template-columns:1fr!important}
 .friend-accept-config{grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important}
 .friend-choice-accept{grid-column:1/-1!important;width:100%!important}
 .friend-choice-decline{width:100%!important}
}
@media(max-width:560px){
 .friend-accept-config{grid-template-columns:1fr!important}
 .friend-choice-accept{grid-column:auto!important}
}
