/* Vista da tavolo (tablet piatto al centro del tavolo). Usa le variabili di app.css. */

/* Lo spessore di un lato è circa il 14% della dimensione più corta dello schermo. */
.tv-tavolo {
  --t: clamp(84px, 14vmin, 180px);
  position: relative; box-sizing: border-box;
  width: 100vw; height: 100vh; height: 100dvh; overflow: hidden;
  display: grid;
  grid-template-columns: var(--t) minmax(0, 1fr) var(--t);
  grid-template-rows: var(--t) minmax(0, 1fr) var(--t);
  background: radial-gradient(ellipse at 50% 50%, var(--panno-chiaro) 0%, var(--panno) 55%, var(--panno-scuro) 100%);
  color: var(--testo);
  font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none;
}

/* ---------- I quattro bordi ---------- */
.tv-bordo { display: flex; min-width: 0; min-height: 0; }
.tv-alto { grid-area: 1 / 1 / 2 / 4; flex-direction: row-reverse; }
.tv-basso { grid-area: 3 / 1 / 4 / 4; flex-direction: row; }
.tv-sinistra { grid-area: 2 / 1 / 3 / 2; flex-direction: column; }
.tv-destra { grid-area: 2 / 3 / 3 / 4; flex-direction: column-reverse; }

/* un posto occupa una porzione del bordo; è un contenitore per le unità cq del testo */
.tv-slot { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; container-type: size; }

/* il lato vero e proprio: centrato nel suo slot e ruotato verso il giocatore */
.tv-lato {
  position: absolute; left: 50%; top: 50%;
  width: 100cqw; height: 100cqh;
  display: flex; align-items: stretch; justify-content: stretch;
  border-radius: var(--raggio); border: 2px solid transparent;
  background: rgba(0, 0, 0, .22);
  transition: background .3s, border-color .3s, box-shadow .3s;
  --cw: calc(var(--t) * .3);
}
.tv-lato.verticale { width: 100cqh; height: 100cqw; }
.tv-lato.turno {
  border-color: var(--oro);
  background: rgba(242, 193, 78, .16);
  box-shadow: 0 0 0 2px rgba(242, 193, 78, .35), 0 0 24px rgba(242, 193, 78, .45);
}

/* il contenuto del lato; lo zoom lo riduce se non ci sta, senza tagliarlo */
.tv-contenuto {
  width: 100%; height: 100%; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: stretch;
  padding: calc(var(--t) * .06) calc(var(--t) * .1);
  text-align: center; overflow: visible;
}
.tv-contenuto > * { margin-left: auto; margin-right: auto; }
.tv-contenuto > :first-child { margin-top: auto; }
.tv-contenuto > :last-child { margin-bottom: auto; }
.tv-nome {
  font-weight: 800; font-size: calc(var(--t) * .2); line-height: 1.1;
  overflow-wrap: anywhere; max-width: 100%;
}
.tv-bot { font-size: .85em; }
.tv-carte { font-size: calc(var(--t) * .15); color: var(--tenue); font-weight: 600; }
/* pallino di presenza per i giocatori umani: verde se collegato, grigio se no */
.tv-presenza { display: inline-block; width: calc(var(--t) * .13); height: calc(var(--t) * .13); border-radius: 50%; margin: 0 auto; background: var(--verde); box-shadow: 0 0 6px var(--verde); }
.tv-presenza.off { background: #777; box-shadow: none; }
.tv-tocca { font-weight: 800; color: var(--oro); font-size: calc(var(--t) * .15); }
.tv-nc { color: var(--rosso); font-size: calc(var(--t) * .13); }
.tv-lato > .tv-contenuto > span,
.tv-lato > .tv-contenuto > .tv-mostrate { font-size: calc(var(--t) * .13); line-height: 1.25; color: #dfe8e2; }
.tv-dealer {
  display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; margin: 0 auto;
  border-radius: 50%; background: var(--oro); color: #2a1e00; font-weight: 800;
}
.tv-mostrate { display: flex; justify-content: center; margin-top: 2px; }
.tv-mostrate .carta { --cw: calc(var(--t) * .3); }
.tv-mostrate .carta + .carta { margin-left: calc(var(--cw) * -.4); }

/* ---------- Il centro: quadrato che ruota verso il giocatore di turno ---------- */
.tv-centro-cella {
  grid-area: 2 / 2 / 3 / 3; position: relative; min-width: 0; min-height: 0;
  container-type: size;
}
.tv-quadrato {
  position: absolute; left: 50%; top: 50%;
  width: min(100cqw, 100cqh); height: min(100cqw, 100cqh);
  container-type: size;
  transition: transform .6s ease;
}
.tv-contenuto-centro {
  position: absolute; inset: 0;
  /* carte grandi in proporzione al quadrato */
  --cw: clamp(28px, 10.5cqmin, 92px);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 2%; font-size: calc(var(--cw) * .24);
}
.tv-contenuto-centro > * { margin-left: auto; margin-right: auto; }
.tv-contenuto-centro > :first-child { margin-top: auto; }
.tv-contenuto-centro > :last-child { margin-bottom: auto; }
.tv-attesa, .tv-semplice { color: var(--tenue); text-align: center; margin: auto; font-size: calc(var(--cw) * .3); }

.tv-centro-gioco {
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--cw) * .22);
  width: 100%; min-height: 0;
}
.tv-riga { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: calc(var(--cw) * .3); }
.tv-blocco { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tv-etich {
  display: block; color: var(--tenue); font-size: max(11px, calc(var(--cw) * .2)); line-height: 1.2;
}
.tv-vuoto { color: var(--tenue); font-size: max(11px, calc(var(--cw) * .22)); font-style: italic; }
.tv-mazzo { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--tenue); }
.tv-mazzo b { font-size: max(14px, calc(var(--cw) * .5)); color: var(--testo); line-height: 1; }
.tv-mazzo span { font-size: max(11px, calc(var(--cw) * .2)); }
.tv-mazzo .carta { box-shadow: 2px 2px 0 #fff, 4px 4px 0 #24408e, 0 4px 10px rgba(0, 0, 0, .4); }

/* carte sovrapposte, come in mano */
.tv-sovrapposte { display: flex; align-items: flex-start; }
.tv-sovrapposte > .carta + .carta { margin-left: calc(var(--cw) * -.66); }
.tv-carte-tavolo { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--cw) * .12); max-width: 100%; }
.tv-ultima { color: var(--testo); display: flex; align-items: center; gap: .5em; flex-wrap: wrap; justify-content: center; font-size: max(12px, calc(var(--cw) * .24)); }
.tv-scopa { color: var(--oro); font-size: 1.4em; letter-spacing: .05em; text-shadow: 0 0 10px rgba(242, 193, 78, .7); }

/* burraco: due squadre affiancate, ogni calata su una riga */
.tv-calate { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--cw) * .3); width: 100%; align-items: start; }
.tv-squadra { display: flex; flex-direction: column; gap: calc(var(--cw) * .14); min-width: 0; }
.tv-squadra h4 { margin: 0; font-size: max(11px, calc(var(--cw) * .24)); color: var(--oro); text-align: center; }
.tv-meld {
  display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 8px;
  border: 1.5px solid transparent; justify-content: center; flex-wrap: wrap;
}
.tv-meld.burraco { border-color: var(--oro); background: rgba(242, 193, 78, .1); }
.tv-meld .badge { font-size: max(10px, calc(var(--cw) * .17)); }

/* machiavelli e scala40: le combinazioni sul tavolo, in righe compatte */
.tv-combinazioni { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--cw) * .2) calc(var(--cw) * .3); width: 100%; }
.tv-comb { display: flex; flex-direction: column; align-items: center; gap: 2px; max-width: 100%; }

/* briscola: griglia 3x3 con le carte giocate verso il lato di chi le ha giocate */
.tv-griglia3 {
  display: grid; width: 100%; height: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
}
.tv-griglia3 > .tv-cella { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; }
.tv-mezzo { display: flex; align-items: center; justify-content: center; gap: calc(var(--cw) * .35); flex-wrap: wrap; }
.tv-briscola { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tv-briscola .carta { transform: rotate(90deg); margin: calc(var(--cw) * .2) 0; }
.tv-giocata { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px; border-radius: 10px; }
.tv-giocata.vincente { outline: 3px solid var(--oro); outline-offset: 2px; }

/* poker: il board e il piatto */
.tv-board { display: flex; gap: calc(var(--cw) * .12); justify-content: center; }
.tv-slot-vuoto {
  width: var(--cw); height: calc(var(--cw) * 1.42);
  border: 2px dashed rgba(255, 255, 255, .25); border-radius: calc(var(--cw) * .1);
}
.tv-piatto { font-weight: 800; color: var(--oro); font-size: max(14px, calc(var(--cw) * .32)); }

/* riepilogo di fine mano / partita */
.tv-riepilogo {
  background: var(--pannello); border: 1px solid var(--bordo); border-radius: var(--raggio);
  box-shadow: var(--ombra); padding: 3% 4%; margin: auto;
  max-width: 100%; text-align: center; font-size: calc(var(--cw) * .24);
}
.tv-riepilogo h2 { color: var(--oro); font-size: 1.5em; margin: 0 0 .3em; }
.tv-riepilogo p { margin: .25em 0; }
.tv-tabella { border-collapse: collapse; margin: .4em auto 0; width: 100%; }
.tv-tabella th, .tv-tabella td { padding: .25em .5em; border-bottom: 1px solid var(--bordo); text-align: right; }
.tv-tabella th { color: var(--tenue); font-weight: 600; text-align: center; }
.tv-tabella td:first-child { text-align: left; color: var(--tenue); }
.tv-tabella tr.totale td { color: var(--oro); font-weight: 800; }

/* il pulsante per ruotare la vista: nell'angolo del centro, sempre fuori dal quadrato */
.tv-ruota {
  position: absolute; left: 8px; top: 8px; z-index: 5;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--bordo); background: rgba(0, 0, 0, .35); color: var(--testo);
  font-size: 24px; line-height: 1; cursor: pointer; touch-action: manipulation;
}
.tv-ruota:active { transform: scale(.94); }
