/* Caratteri ospitati sul sito (licenza OFL, vedi fonts/): nessuna richiesta a servizi esterni. */
@font-face {
  font-family: "Fredoka"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url(../fonts/fredoka-latin-wght-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url(../fonts/nunito-latin-wght-normal.woff2) format("woff2");
}

/* Stile cartoon: contorno scuro spesso (come nelle illustrazioni) e ombre piene sfalsate. */
:root {
  --font-body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-title: "Fredoka", "Nunito", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --ink: #3b2a20;
  --line-w: 2.5px;
  --outline: var(--line-w) solid var(--ink);
  --pop: 0 3px 0 var(--ink);
  --bg: #fbf0dc;
  --paper: #fffaf1;
  --muted: #7a604e;
  --accent: #d9583c;
  --accent-dark: #a5402b;
  --mustard: #f2bd4b;
  --wood: #c98446;
  --wood-dark: #9a5b2a;
  --chair: #fff3dc;
  --sky: #bfe6f7;
  --ok: #4f8a3c;
  --ok-bg: #dff0d2;
  --ko: #d9583c;
  --ko-bg: #fde0d6;
  --chair-size: 70px;
  --plate: 32px;
  --plate-edge: 19px;   /* distanza del centro del piatto dal bordo della tavola */
  --dish: 42px;
  --check: 22px;        /* lato di 2 quadretti della tovaglia */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--font-body);
  padding-bottom: 120px; /* spazio per la barra in basso */
}
button, .person, .seat { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
h1 { font-family: var(--font-title); font-weight: 600; font-size: 1.6rem; line-height: 1.15; margin: 10px 0 8px; text-align: center; }
h2 { font-family: var(--font-title); font-size: .95rem; font-weight: 600; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- Intestazione a forma di tenda da trattoria ---------- */
.top {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 14px 6px; background: var(--accent); color: #fff;
  border-bottom: var(--outline);
  margin-bottom: 16px;
}
/* smerlo della tenda, con il suo contorno */
.top::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px; margin-top: var(--line-w);
  background:
    radial-gradient(circle at 10px 0, var(--accent) 8.5px, var(--ink) 9px, var(--ink) 11px, transparent 11.5px) repeat-x;
  background-size: 22px 12px;
  margin-top: 0;
}
.brand {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-title); font-weight: 700; font-size: 1.5rem; letter-spacing: .01em;
  text-shadow: 0 2px 0 var(--ink);
  white-space: nowrap;
}
.brand .logo { width: 40px; height: 40px; margin: -4px 0; filter: drop-shadow(0 2px 0 rgba(59, 42, 32, .35)); }
.brand span { font-weight: 500; font-size: 1.1rem; opacity: .95; }
.top-actions { display: flex; gap: 6px; }
.chip {
  border: var(--outline); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 2px 11px; font-weight: 800; font-size: .85rem; min-height: 34px;
  box-shadow: 0 2px 0 var(--ink);
}
.chip:active { transform: translateY(2px); box-shadow: none; }
.chip.round { width: 34px; padding: 0; }
/* Lingua: si vede il codice (IT, EN…), il menu nativo trasparente sopra apre l'elenco con i nomi completi */
.lang-chip { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
.lang-chip::after { content: ""; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0; margin-top: 2px; }
.lang-chip select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.lang-chip:focus-within { outline: 3px solid var(--mustard); outline-offset: 1px; }

main { max-width: 560px; margin: 0 auto; padding: 12px 16px; }
.notice {
  background: var(--mustard); border: var(--outline); border-radius: 12px; box-shadow: var(--pop);
  padding: 8px 12px; font-size: .9rem; font-weight: 700; text-align: center;
}

/* ---------- Tavola ---------- */
/* Pavimento in cotto */
.board {
  display: grid;
  grid-template-columns: var(--chair-size) minmax(90px, 140px) var(--chair-size) 30px;
  justify-content: center;
  gap: 6px;
  margin: 0 auto 22px;
  padding: 28px 8px;
  border: var(--outline);
  border-radius: 22px;
  box-shadow: var(--pop);
  background-color: #f1d3ae;
  background-image:
    linear-gradient(rgba(154, 91, 42, .2) 2px, transparent 2px),
    linear-gradient(90deg, rgba(154, 91, 42, .2) 2px, transparent 2px);
  background-size: 36px 36px;
  background-position: -1px -1px;
  user-select: none; -webkit-user-select: none;
}
/* Tovaglia a quadretti: colori presi dall'illustrazione (art/tavola.png) */
.table-top {
  position: relative;
  background: #fbdec6 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22'%3E%3Crect width='22' height='22' fill='%23fbdec6'/%3E%3Crect width='11' height='22' fill='%23ec896c'/%3E%3Crect width='22' height='11' fill='%23ec896c'/%3E%3Crect width='11' height='11' fill='%23d2452d'/%3E%3C/svg%3E") 0 0 / var(--check) var(--check);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 5px 0 var(--ink);
}
/* cibi in colonna al centro; sopra e sotto resta posto per i piatti dei capotavola */
.food {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(var(--plate-edge) + var(--plate) / 2 + 4px); bottom: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-evenly;
  pointer-events: none;
}
.food.two-heads { bottom: calc(var(--plate-edge) + var(--plate) / 2 + 4px); }
.food img { width: var(--dish); height: var(--dish); display: block; filter: drop-shadow(0 2px 0 rgba(59, 42, 32, .35)); }
.plate {
  position: absolute; width: var(--plate); height: var(--plate);
  margin: calc(var(--plate) / -2) 0 0 calc(var(--plate) / -2);
  background: url(../img/table/plate.webp) center / contain no-repeat;
  filter: drop-shadow(0 2px 0 rgba(59, 42, 32, .35));
}
/* il piatto si riempie quando qualcuno si siede */
.plate.served { background-image: url(../img/table/plate-full.webp); animation: serve .3s ease-out; }
@keyframes serve { 0% { transform: scale(.7); } 70% { transform: scale(1.1); } 100% { transform: none; } }
/* Finestra (margine a sinistra: lo schienale delle sedie di destra non la tocca) */
.window-strip {
  position: relative; margin-left: 8px;
  border: var(--outline);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent calc(50% - 1.5px), var(--wood-dark) calc(50% - 1.5px) calc(50% + 1.5px), transparent calc(50% + 1.5px)),
    repeating-linear-gradient(180deg, var(--sky) 0 26px, var(--wood-dark) 26px 30px),
    var(--sky);
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .7), var(--pop);
}
.window-strip span {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 8px;
  font-family: var(--font-title); font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: #24566d;
  white-space: nowrap;
}
/* Sedie: illustrazione vista dall'alto (schienale in alto), girata secondo il lato */
.seat {
  width: var(--chair-size); min-height: var(--chair-size);
  display: flex; align-items: center; justify-content: center;
  position: relative; isolation: isolate; /* la sedia (::before, z-index -1) resta sotto al parente ma sopra al pavimento */
  border-radius: 18px;
}
.seat::before {
  content: ""; position: absolute; left: 50%; top: 50%; z-index: -1;
  width: var(--chair-size); height: var(--chair-size);
  background: url(../img/table/chair.webp) center / contain no-repeat;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 3px 0 rgba(59, 42, 32, .35));
  transition: filter .15s;
}
.seat.head-bottom::before { transform: translate(-50%, -50%) rotate(180deg); }
.seat.side-left::before { transform: translate(-50%, -50%) rotate(-90deg); }
.seat.side-right::before { transform: translate(-50%, -50%) rotate(90deg); }
/* il parente si siede sul cuscino, non sullo schienale */
.seat.head-top { padding-top: 10px; }
.seat.head-bottom { padding-bottom: 10px; }
.seat.side-left { padding-left: 10px; }
.seat.side-right { padding-right: 10px; }
.seat.head::after {
  content: attr(data-label);
  position: absolute; top: -6px; left: 50%; transform: translate(-50%, -100%);
  font-family: var(--font-title); font-size: .66rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; white-space: nowrap;
}
.seat.head.head-bottom::after { top: auto; bottom: -6px; transform: translate(-50%, 100%); }
.seat .person { position: relative; }
.seat .pname {
  background: #fff; border: 1.5px solid var(--ink); border-radius: 8px; padding: 1px 4px; margin-top: -6px;
  position: relative; max-width: calc(var(--chair-size) - 4px);
}
.seat.hover::before, .seat.target::before { filter: drop-shadow(0 0 0 var(--mustard)) drop-shadow(0 0 5px var(--mustard)) drop-shadow(0 3px 0 rgba(59, 42, 32, .35)); }
.tray.hover { background: #ffe7a8; }
.seat.target:not(.filled) { animation: invite 1.4s ease-in-out infinite; }
@keyframes invite { 50% { transform: scale(1.06); } }
/* il parente "salta" quando si siede */
.seat.filled .avatar { animation: hop .35s ease-out; }
@keyframes hop { 0% { transform: translateY(-8px) scale(.9); } 60% { transform: translateY(1px) scale(1.04); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .seat.target:not(.filled), .seat.filled .avatar, .plate.served { animation: none; } }

/* ---------- Parenti ---------- */
.person {
  touch-action: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px; width: 100%;
  border-radius: 14px;
}
.person.selected { outline: 3px solid var(--accent); outline-offset: 1px; background: #fff; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-title); font-weight: 700; font-size: 1.2rem;
  overflow: hidden; flex: none;
  border: var(--outline);
  box-shadow: 0 2px 0 var(--ink);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.pname { font-family: var(--font-title); font-size: .7rem; line-height: 1.05; text-align: center; font-weight: 600; word-break: break-word; }

.tray {
  background: var(--paper); border-radius: 20px; padding: 14px 12px; margin-bottom: 22px;
  border: var(--outline); box-shadow: var(--pop);
}
.tray-list { display: flex; flex-direction: column; gap: 10px; }
.tray .person {
  flex-direction: row; align-items: center; gap: 12px;
  background: #fff; border: var(--outline); padding: 8px 12px 8px 8px; text-align: left;
  box-shadow: 0 3px 0 var(--ink);
}
.tray .person.selected { outline-offset: 2px; background: #fff7e2; }
.tray .avatar { width: 58px; height: 58px; font-size: 1.5rem; }
.tray .person { touch-action: pan-y; }  /* la scheda lascia scorrere la pagina... */
.tray .person .avatar { touch-action: none; }  /* ...e si trascina dal cerchio */
.tray .pname { font-size: 1.05rem; text-align: left; }
.tray .quirk { font-size: .87rem; color: var(--muted); line-height: 1.3; }
.tray .ptext { display: flex; flex-direction: column; gap: 2px; }
.tray-empty { color: var(--ok); font-weight: 800; margin: 4px 0; }

.ghost {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  transform-origin: center;
}
.ghost .avatar { width: 58px; height: 58px; box-shadow: 0 8px 16px rgba(0,0,0,.3); transform: rotate(-6deg); }

/* ---------- Indizi ---------- */
.clues ol { margin: 0; padding: 0; list-style: none; counter-reset: c; display: flex; flex-direction: column; gap: 10px; }
.clues li {
  counter-increment: c;
  background: #fff; border-radius: 16px; padding: 11px 12px 11px 48px; position: relative;
  border: var(--outline); box-shadow: 0 3px 0 var(--ink);
  transition: background .2s;
}
.clues li::before {
  content: counter(c);
  position: absolute; left: 10px; top: 9px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--mustard); color: var(--ink); border: 2px solid var(--ink);
  font-family: var(--font-title); font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
}
.clues li.ok { background: var(--ok-bg); }
.clues li.ok::before { content: "✓"; background: var(--ok); color: #fff; }
.clues li.ko { background: var(--ko-bg); }
.clues li.ko::before { content: "✗"; background: var(--ko); color: #fff; }

/* ---------- Barra in basso ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(251, 240, 220, .97);
  border-top: var(--outline);
  padding: 8px 16px calc(10px + env(safe-area-inset-bottom));
}
.bar-info { max-width: 560px; margin: 0 auto 6px; font-size: .88rem; min-height: 1.2em; text-align: center; }
.bar-info:empty { display: none; }
.bar-row { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; }
.primary, .secondary {
  flex: 1; min-height: 50px; border-radius: 14px; border: var(--outline);
  font-family: var(--font-title); font-weight: 600; font-size: 1.15rem; letter-spacing: .01em;
  box-shadow: 0 4px 0 var(--ink); margin-bottom: 4px;
}
.primary { background: var(--accent); color: #fff; text-shadow: 0 1.5px 0 rgba(59, 42, 32, .6); }
.primary:active, .secondary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.primary:disabled { background: #e6d3bf; color: #fff; text-shadow: none; border-color: #b9a08a; box-shadow: 0 4px 0 #b9a08a; cursor: default; transform: none; }
.secondary { background: #fff; color: var(--accent-dark); }

/* ---------- Finestre sovrapposte ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(59, 42, 32, .6);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 24px 16px;
}
.overlay[hidden] { display: none; }
.card {
  background: var(--paper); border-radius: 22px; padding: 20px; max-width: 480px; width: 100%;
  border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink);
}
.card h2 { font-size: 1.6rem; color: var(--ink); text-transform: none; letter-spacing: 0; }
.card h3 { font-family: var(--font-title); font-weight: 600; font-size: 1.1rem; margin: 16px 0 8px; }
.card dl { margin: 8px 0 16px; }
.card dt { font-family: var(--font-title); font-weight: 600; margin-top: 10px; }
.card dd { margin: 2px 0 0; color: #5a4436; }
.guide-figure { display: flex; justify-content: center; margin: 4px 0; }
.guide-figure svg { width: 100%; max-width: 280px; height: auto; }
.end-card { text-align: center; }
.end-art { display: block; width: 120px; height: 120px; margin: -6px auto 0; }
.stats { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; }
.stat-label { display: block; font-size: .8rem; font-weight: 800; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--font-title); font-size: 2.6rem; font-weight: 700; }
.stat-value.small { font-family: var(--font-body); font-size: 1rem; font-weight: 700; }
.muted { color: var(--muted); font-size: .9rem; }

.foot { text-align: center; margin: 24px 0 8px; font-size: .85rem; }
.foot a, .card a { color: var(--accent-dark); font-weight: 700; }
.share-msg { min-height: 1.2em; margin: 8px 0 0; font-size: .9rem; color: var(--ok); font-weight: 700; }
.share-msg:empty { display: none; }
.share-fallback { width: 100%; font: inherit; font-size: .9rem; padding: 8px; border-radius: 10px; border: 2px solid var(--ink); resize: none; }
.end-card .primary, .card > .primary, .card > .secondary { width: 100%; }
.waitlist { text-align: left; background: #fff; border: var(--outline); border-radius: 16px; padding: 14px; margin: 18px 0 8px; box-shadow: 0 3px 0 var(--ink); }
.waitlist h3 { margin: 0 0 10px; font-size: 1.05rem; }
.waitlist input[type=email] {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; min-height: 46px;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--paper);
}
.consent { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; margin: 10px 0; color: #5a4436; }
.consent input { width: 20px; height: 20px; flex: none; margin: 1px 0 0; accent-color: var(--accent); }
.wl-msg { margin: 8px 0 0; font-size: .9rem; font-weight: 700; }
.wl-msg:empty { display: none; }
.wl-msg.ok { color: var(--ok); }
.wl-msg.err { color: var(--ko); }
.end-links { display: flex; justify-content: center; gap: 20px; margin-top: 8px; }
.linkish { background: none; border: none; color: var(--accent-dark); text-decoration: underline; padding: 8px 4px; font-weight: 800; }
.archive-list { list-style: none; padding: 0; margin: 8px 0 16px; display: flex; flex-direction: column; gap: 10px; }
.archive-list a, .archive-list .locked {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 14px; background: #fff; border: var(--outline); box-shadow: 0 3px 0 var(--ink);
  color: var(--ink); text-decoration: none;
}
.archive-list .current { background: #fff3d4; }
.archive-list .locked { background: transparent; color: var(--muted); border-style: dashed; border-color: #b9a08a; box-shadow: none; }
.archive-list .atitle { font-family: var(--font-title); font-weight: 600; }
.archive-list .astatus { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.archive-list .astatus.done { color: var(--ok); font-weight: 800; }

@media (min-width: 600px) {
  :root { --chair-size: 88px; }
  .board { grid-template-columns: var(--chair-size) 160px var(--chair-size) 36px; gap: 10px; padding: 32px 24px; }
  .avatar { width: 56px; height: 56px; }
  :root { --plate: 38px; --plate-edge: 23px; --dish: 56px; --check: 26px; }
  .pname { font-size: .78rem; }
}
@media (max-width: 430px) {
  .top { padding: 8px 10px 6px; }
  .brand { font-size: 1.25rem; gap: 4px; }
  .brand .logo { width: 34px; height: 34px; }
  .brand span { font-size: .95rem; }
  .top-actions { gap: 5px; }
  .chip { padding: 2px 9px; font-size: .8rem; min-height: 32px; }
  .chip.round { width: 32px; }
}
@media (max-width: 350px) {
  :root { --chair-size: 62px; }
  .board { grid-template-columns: var(--chair-size) minmax(70px, 1fr) var(--chair-size) 26px; gap: 4px; padding: 26px 4px; }
  .avatar { width: 40px; height: 40px; }
  :root { --plate: 22px; --plate-edge: 15px; --dish: 32px; --check: 18px; }
  .top { padding: 8px 8px 6px; gap: 4px; }
  .brand { font-size: 1.05rem; gap: 3px; }
  .brand .logo { width: 26px; height: 26px; }
  .brand span { font-size: .85rem; }
  .top-actions { gap: 4px; }
  .chip { padding: 2px 6px; font-size: .76rem; }
  .chip.round { width: 30px; min-height: 30px; }
}
