/* Cialfi's Solitaire | stile */

:root {
  --font-ui: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-indice: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-figure: "Palatino Linotype", "Book Antiqua", Palatino, "Times New Roman", serif;
  --cw: 100px;
  --ch: 140px;
  --cr: 7px;
  --oro: #ffd56b;
  --rosso: #c4232f;
  --nero: #1f2024;
  --blu-quadri: #1f5fbf;
  --verde-fiori: #1e7a3c;
  --pannello: #fbfaf6;
  --testo: #23262b;
}

body[data-tavolo="verde"] {
  --panno: #1d5a3b; --panno-chiaro: #27704b; --panno-scuro: #113723; --dorso: #9b2335;
}
body[data-tavolo="blu"] {
  --panno: #1c3f66; --panno-chiaro: #275482; --panno-scuro: #0f2540; --dorso: #a3283a;
}
body[data-tavolo="bordeaux"] {
  --panno: #5e1d2c; --panno-chiaro: #772738; --panno-scuro: #3a101a; --dorso: #1f4a7a;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-ui);
  color: #f5f1e6;
  background: radial-gradient(ellipse at 50% 30%, var(--panno-chiaro), var(--panno) 55%, var(--panno-scuro));
  background-color: var(--panno);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* grana leggera del panno */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.simboli { position: absolute; width: 0; height: 0; overflow: hidden; }

/* testata */
.testata {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px 4px;
  flex-wrap: wrap;
}
.testata h1 {
  margin: 0;
  font-family: var(--font-figure);
  font-style: italic;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .01em;
  color: #f7f0dc;
}
.info {
  display: flex;
  gap: 8px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: rgba(245, 241, 230, .85);
}
.info .sep { opacity: .45; }

/* tavolo */
#tavolo {
  position: relative;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
}
#piano {
  position: relative;
  width: 100%;
  min-height: 100%;
  touch-action: pan-y;
}

/* posti vuoti */
.posto {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: var(--cr);
  border: 2px solid rgba(255, 255, 255, .2);
  background: rgba(0, 0, 0, .1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, .22);
  font-family: var(--font-figure);
  font-weight: 700;
  font-size: calc(var(--cw) * .42);
  touch-action: none;
}
.posto[data-pila="mazzo"] { cursor: pointer; }
.posto svg {
  width: 42%;
  height: 42%;
  fill: none;
  stroke: rgba(255, 255, 255, .5);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: none;
}
.posto.rigira svg { display: block; }

/* carte */
.carta {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cw);
  height: var(--ch);
  perspective: 900px;
  transition: transform .26s cubic-bezier(.2, .7, .3, 1);
  touch-action: none;
  cursor: pointer;
  will-change: transform;
}
.giro {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .32s ease;
}
.carta.coperta .giro { transform: rotateY(180deg); }
.fronte, .dorso {
  position: absolute;
  inset: 0;
  border-radius: var(--cr);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .25), 0 2px 6px rgba(0, 0, 0, .18);
}
.fronte {
  background: #fffdf8;
  border: 1px solid rgba(0, 0, 0, .18);
}
.dorso {
  transform: rotateY(180deg);
  background: var(--dorso);
  color: var(--dorso);
  border: 1px solid rgba(0, 0, 0, .25);
}
.fronte svg, .dorso svg { display: block; width: 100%; height: 100%; }

.seme-s, .seme-c { color: var(--nero); }
.seme-h, .seme-d { color: var(--rosso); }
.seme-s .tinta, .seme-c .tinta { fill: #eef1f5; }
.seme-h .tinta, .seme-d .tinta { fill: #fbeeee; }
body.quattro-colori .seme-d { color: var(--blu-quadri); }
body.quattro-colori .seme-c { color: var(--verde-fiori); }
body.quattro-colori .seme-d .tinta { fill: #eaf1fb; }
body.quattro-colori .seme-c .tinta { fill: #e9f4ec; }

.carta .valore { font: 700 44px var(--font-indice); }
.carta .valore.dieci { letter-spacing: -4px; }
.carta .lettera { font: 700 88px var(--font-figure); }
.dorso .monogramma { font: italic 700 40px var(--font-figure); fill: #fff; }

.carta.sotto .fronte, .carta.sotto .dorso { box-shadow: none; }
.carta.trascinata { transition: none; }
.carta.trascinata .fronte { box-shadow: 0 6px 16px rgba(0, 0, 0, .35), 0 2px 4px rgba(0, 0, 0, .2); }

.senza-animazione .carta,
.senza-animazione .giro { transition: none !important; }

/* suggerimenti e bersagli */
@keyframes luce {
  from { box-shadow: 0 0 0 0 rgba(255, 213, 107, 0), 0 2px 6px rgba(0, 0, 0, .18); }
  to { box-shadow: 0 0 0 3px var(--oro), 0 0 18px 4px rgba(255, 213, 107, .75); }
}
.carta.suggerita .fronte,
.carta.suggerita .dorso { animation: luce .45s ease-in-out 4 alternate; }

.bersaglio {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: var(--cr);
  pointer-events: none;
  z-index: 2500;
  box-shadow: 0 0 0 3px var(--oro), 0 0 16px 3px rgba(255, 213, 107, .6);
}
.bersaglio.lampeggia { animation: luce .45s ease-in-out 4 alternate; box-shadow: none; }

@keyframes scuoti {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.carta.scuoti .giro { animation: scuoti .22s ease 2; }

/* barra dei comandi */
.comandi {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, .2);
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.comandi button {
  flex: 0 1 120px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #f5f1e6;
  font: 500 13px var(--font-ui);
  cursor: pointer;
}
.comandi button:hover { background: rgba(255, 255, 255, .1); }
.comandi button:disabled { opacity: .4; cursor: default; background: transparent; }
.comandi button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.comandi svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* menu della partita */
.menu {
  position: fixed;
  z-index: 50;
  min-width: 220px;
  padding: 4px;
  background: var(--pannello);
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: var(--testo);
  font: 15px var(--font-ui);
  text-align: left;
  cursor: pointer;
}
.menu button:hover { background: rgba(0, 0, 0, .07); }

/* avvisi */
.avviso {
  position: fixed;
  left: 50%;
  bottom: 84px;
  z-index: 40;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 2px;
  background: var(--pannello);
  color: var(--testo);
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.avviso.visibile { opacity: 1; transform: translate(-50%, 0); }

/* finestre */
.finestra {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 20px 22px 16px;
  border: 0;
  border-radius: 2px;
  background: var(--pannello);
  color: var(--testo);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .45);
  -webkit-user-select: text;
  user-select: text;
}
.finestra::backdrop { background: rgba(0, 0, 0, .4); }
.finestra h2 {
  margin: 0 0 12px;
  font-family: var(--font-figure);
  font-size: 22px;
}
.finestra fieldset {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.finestra legend {
  padding: 0;
  margin-bottom: 4px;
  font-weight: 600;
  font-size: 14px;
  color: #555b63;
}
.finestra label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  font-size: 15px;
  line-height: 1.35;
  cursor: pointer;
}
.finestra input { margin: 3px 0 0; accent-color: var(--panno); }
.finestra .nota { margin: 4px 0 0; font-size: 13px; color: #6a7078; }
.finestra p { line-height: 1.45; }
.pulsanti {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.pulsanti button {
  min-width: 110px;
  padding: 9px 16px;
  border-radius: 2px;
  font: 600 14px var(--font-ui);
  cursor: pointer;
}
.primario { border: 1px solid var(--panno); background: var(--panno); color: #fff; }
.primario:hover { background: var(--panno-chiaro); }
.secondario { border: 1px solid var(--panno); background: #fff; color: var(--panno); }
.secondario:hover { background: #f1f1ec; }

.tabella-stat {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.tabella-stat th, .tabella-stat td {
  padding: 7px 6px;
  border-bottom: 1px solid #e3e1da;
  text-align: right;
}
.tabella-stat th:first-child, .tabella-stat td:first-child { text-align: left; }
.tabella-stat thead th { font-size: 13px; color: #555b63; }

/* telefono */
@media (max-width: 600px) {
  .testata { padding: 6px 12px 2px; gap: 2px 10px; }
  .testata h1 { font-size: 18px; }
  .info { font-size: 12px; gap: 6px; }
  .comandi button { font-size: 11px; padding: 5px 2px; }
  .avviso { bottom: 76px; font-size: 14px; }
}
