/* Cluedo: interfaccia "fascicolo d'indagine". Pelle scura e carta invecchiata, ottone, rosso sangue di bue,
   macchina da scrivere per le annotazioni. */
:root {
  --bg: #120a07;
  --card: #f1e7cf;
  --card-hi: #f8f1de;
  --card-2: #e3d5b4;
  --ink: #2a1a12;
  --ink-2: #4d3a2c;
  --ink-3: #7a6650;
  --rule: rgba(42, 26, 18, 0.16);
  --rule-2: rgba(42, 26, 18, 0.32);
  --red: #8f1d24;
  --red-dk: #681419;
  --red-ink: #8f1d24;
  --brass: #a8822f;
  --brass-hi: #d4ae5a;
  --green: #24513f;
  --pos: #2a7049;
  --solid: #2a1a12;
  --on-solid: #f8f1de;
  --edge: rgba(42, 26, 18, 0.3);
  --hover: rgba(42, 26, 18, 0.07);
  --paper-card: #f3e9d2;      /* carte indizio e taccuino: carta chiara in entrambi i temi */
  --paper-ink: #2a1a12;
  --lift: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 2px 3px rgba(20, 8, 4, 0.3), 0 16px 34px -12px rgba(20, 8, 4, 0.7);
  --paper: linear-gradient(transparent, transparent);

  --display: 'Playfair Display', 'Bodoni 72', Didot, Georgia, serif;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'Libre Franklin', 'Helvetica Neue', Arial, sans-serif;
  --type: 'Special Elite', 'Courier New', monospace;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --r-card: 6px;
  --r-btn: 4px;
  --panel-w: 360px;
  --hand-w: 290px;            /* spazio riservato alla mano in basso a sinistra */
  color-scheme: light;
}

:root[data-theme="dark"] {
  --card: #241913;
  --card-hi: #2e211a;
  --card-2: #3a2b22;
  --ink: #f1e6cd;
  --ink-2: #cdbd9f;
  --ink-3: #9a8a71;
  --rule: rgba(241, 230, 205, 0.12);
  --rule-2: rgba(241, 230, 205, 0.28);
  --red: #9b2129;
  --red-dk: #74161c;
  --red-ink: #ec8a80;
  --brass: #c9a54a;
  --pos: #7cc79a;
  --solid: #e9dcbc;
  --on-solid: #1d130e;
  --edge: rgba(0, 0, 0, 0.6);
  --hover: rgba(241, 230, 205, 0.07);
  --lift: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 2px 3px rgba(0, 0, 0, 0.5), 0 16px 34px -12px rgba(0, 0, 0, 0.85);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
input, select { user-select: text; }
:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 75% at 50% 45%, transparent 50%, rgba(8, 3, 1, 0.7) 100%);
}

.card {
  background: var(--paper), var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  box-shadow: var(--lift);
  color: var(--ink);
}
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.wordmark { font-family: var(--display); font-weight: 900; letter-spacing: 0.14em; margin: 0; line-height: 1; }
.code { font-family: var(--mono); font-weight: 800; letter-spacing: 0.14em; }

/* ---------- pulsanti ---------- */
.btn {
  --bg: transparent; --fg: var(--ink); --bd: var(--rule-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1.5px solid var(--bd); border-radius: var(--r-btn); cursor: pointer;
  padding: 8px 15px; font-weight: 600; font-size: 0.92rem; line-height: 1.2;
  background: var(--bg); color: var(--fg);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
  transition: background-color 0.15s, transform 0.08s, filter 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background-color: var(--hover); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { --bg: var(--red); --fg: #f8efd9; --bd: var(--red-dk); }
.btn.primary:hover:not(:disabled) { background: var(--red); filter: brightness(1.1); }
.btn.danger { --bg: var(--solid); --fg: var(--on-solid); --bd: var(--solid); }
.btn.danger:hover:not(:disabled) { background: var(--solid); filter: brightness(1.15); }
.btn.ghost { --bd: transparent; box-shadow: none; }
.btn.big { padding: 12px 20px; font-size: 1rem; width: 100%; }
.btn.small { padding: 5px 10px; font-size: 0.82rem; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--edge); background: var(--paper), var(--card); color: var(--ink); cursor: pointer;
  box-shadow: var(--lift);
}
.icon-btn .ic { width: 20px; height: 20px; }
.icon-btn:hover { filter: brightness(1.08); }
.icon-btn.on { background: var(--solid); color: var(--on-solid); }
.icon-btn.danger { color: var(--red-ink); }
.icon-btn.tiny { width: 26px; height: 26px; box-shadow: none; }
.icon-btn.tiny .ic { width: 14px; height: 14px; }

/* ---------- campi ---------- */
.field { display: grid; gap: 5px; }
.field > span { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.field input, .field select, .join-row input {
  padding: 10px 12px; border-radius: var(--r-btn); border: 1.5px solid var(--rule-2);
  background: var(--card-hi); color: var(--ink); width: 100%;
}
.field input:focus, .join-row input:focus, .field select:focus { border-color: var(--brass); outline: none; }
.field.compact input, .field.compact select { padding: 7px 10px; }
.field select:disabled { opacity: 0.7; }

/* ---------- caricamento ---------- */
#loader {
  position: fixed; inset: 0; display: grid; place-content: center; gap: 18px; justify-items: center; z-index: 100;
  background: radial-gradient(circle at 50% 40%, #2a1210, #0c0605); color: #efe3c4; transition: opacity 0.7s;
}
#loader.gone { opacity: 0; pointer-events: none; }
.loader-mark { font-size: clamp(48px, 9vw, 96px); color: #d8b65e; text-shadow: 0 4px 30px rgba(216, 182, 94, 0.25); }
.loader-bar { width: 220px; height: 3px; background: rgba(239, 227, 196, 0.15); border-radius: 2px; overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 5%; background: #d8b65e; transition: width 0.6s; }
.loader-text { font-family: var(--type); font-size: 0.95rem; opacity: 0.75; }

/* ---------- schermate ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; z-index: 10; }
.deal-in { animation: dealIn 0.55s cubic-bezier(.2, .9, .3, 1.1) both; }
@keyframes dealIn { from { opacity: 0; transform: translateY(24px) rotate(-1.2deg) scale(0.97); } }

.home-card { width: min(440px, 100%); overflow: hidden; }
.lid {
  padding: 30px 26px 24px; text-align: center; color: #efe3c4;
  background: radial-gradient(circle at 50% 0%, #a3262e, #5e1015 80%);
  border-bottom: 3px double #c9a54a;
}
.lid h1 { font-size: clamp(48px, 13vw, 70px); color: #f2dfa8; text-shadow: 0 3px 0 #3a0a0d, 0 8px 26px rgba(0, 0, 0, 0.5); }
.lid-kicker { font-family: var(--type); letter-spacing: 0.12em; font-size: 0.8rem; text-transform: uppercase; opacity: 0.85; margin-bottom: 10px; }
.lid-sub { font-family: var(--display); font-style: italic; margin-top: 12px; font-size: 1.02rem; opacity: 0.9; }
.home-body { padding: 22px 24px 20px; display: grid; gap: 14px; }
.btn.solo { --bd: var(--rule-2); }
.join { display: grid; gap: 6px; padding-top: 6px; border-top: 1px dashed var(--rule-2); }
.join-row { display: flex; gap: 8px; }
.join-row input { font-family: var(--mono); font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; }
.fineprint { margin: 0; font-size: 0.8rem; color: var(--ink-3); text-align: center; }

/* ---------- lobby ---------- */
.lobby-card { width: min(1080px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.lobby-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 22px; background: linear-gradient(#7d1a20, #5e1015); color: #efe3c4; border-bottom: 3px double #c9a54a;
}
.lobby-head .btn { --fg: #efe3c4; }
.lobby-head .btn:hover { background: rgba(255, 255, 255, 0.08); }
.lobby-ticket { display: flex; align-items: baseline; gap: 12px; }
.ticket-label { font-family: var(--type); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.8rem; opacity: 0.85; }
#lobby-code { font-size: 2rem; color: #f2dfa8; }
.lobby-body { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 22px; padding: 18px 22px; overflow-y: auto; }
.lobby-col h3 { font-family: var(--display); font-size: 1.15rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.count { font-family: var(--sans); font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }
.lobby-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.lobby-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 5px; background: var(--hover); }
.lobby-list li.off { opacity: 0.55; }
.lobby-list li.spect { font-size: 0.85rem; color: var(--ink-3); background: none; }
.portrait { display: block; border-radius: 4px; flex: none; }
.portrait.mini { border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.25); }
.ll-name { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.ll-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ll-name small { color: var(--ink-3); font-size: 0.78rem; }
.ll-tags { display: flex; align-items: center; gap: 4px; }
.tag { font-size: 0.7rem; font-weight: 700; padding: 2px 6px; border-radius: 3px; background: var(--rule); text-transform: uppercase; letter-spacing: 0.05em; display: inline-flex; }
.tag.host { color: var(--brass); background: none; }
.tag.me { background: var(--red); color: #f8efd9; }
.add-bot { width: 100%; border: 1.5px dashed var(--rule-2) !important; }
.suspect-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.suspect-opt {
  display: grid; justify-items: center; gap: 4px; padding: 8px 6px 9px; cursor: pointer; border-radius: 6px;
  border: 2px solid var(--rule); background: var(--card-hi); transition: transform 0.12s, border-color 0.12s;
}
.suspect-opt .portrait { width: 100%; height: auto; aspect-ratio: 1; border-radius: 4px; }
.suspect-opt:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--sc); }
.suspect-opt.sel { border-color: var(--sc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sc) 35%, transparent); }
.suspect-opt.taken { opacity: 0.45; cursor: default; filter: grayscale(0.6); }
.so-name { font-family: var(--display); font-weight: 700; font-size: 0.86rem; text-align: center; line-height: 1.15; }
.so-owner { font-size: 0.72rem; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.suspect-opt.sel .so-owner { color: var(--red-ink); }
.host-note, .rules-note { font-size: 0.82rem; color: var(--ink-3); margin: 0 0 10px; }
.rules-note { margin-top: 12px; font-family: var(--type); line-height: 1.5; }
.lobby-col .field { margin-bottom: 10px; }
.lobby-foot { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-top: 1px solid var(--rule); }
.lobby-foot .hint { flex: 1; text-align: right; font-size: 0.85rem; color: var(--ink-3); }
.lobby-foot .btn.big { width: auto; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }

.hud-players {
  position: absolute; left: 14px; top: 14px; display: grid; gap: 6px; width: 246px; padding-right: 12px;
  max-height: calc(100vh - 300px); overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;                   /* niente barra: con 6 investigatori la lista ci sta comunque */
}
.hud-players::-webkit-scrollbar { display: none; }
.pl {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px 6px 6px; border-radius: 30px 8px 8px 30px;
  background: var(--paper), var(--card); border: 1px solid var(--edge); box-shadow: var(--lift);
  border-left: 4px solid var(--pc); transition: transform 0.2s;
}
.pl.cur { transform: translateX(8px); box-shadow: 0 0 0 2px var(--brass-hi), var(--lift); }
.pl.off { opacity: 0.6; }
.pl.out .pl-name { text-decoration: line-through; text-decoration-color: var(--red-ink); }
.pl.gone { opacity: 0.4; }
.pl.me .pl-name::after { content: 'tu'; margin-left: 6px; font-size: 0.65rem; background: var(--red); color: #f8efd9; padding: 1px 5px; border-radius: 3px; vertical-align: 2px; }
.pl .portrait { width: 36px; height: 36px; }
.pl-body { flex: 1; min-width: 0; line-height: 1.2; }
.pl-name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.pl-ic { width: 13px; height: 13px; color: var(--ink-3); }
.pl-sub { font-size: 0.75rem; color: var(--ink-3); }
.pl-sub em { color: var(--red-ink); font-style: normal; font-weight: 600; }
.pl-cards { display: flex; align-items: center; gap: 3px; font-family: var(--serif); font-weight: 700; font-size: 0.9rem; color: var(--ink-2); }
.pl.spect { border-left-color: var(--ink-3); font-size: 0.8rem; color: var(--ink-3); padding-left: 12px; }

.hud-tools { position: absolute; right: 14px; top: 14px; display: flex; gap: 8px; }
body.panel-open .hud-tools { right: calc(var(--panel-w) + 28px); }

.side-panel {
  position: absolute; right: 14px; top: 14px; bottom: 14px; width: var(--panel-w);
  display: flex; flex-direction: column; overflow: hidden; transform: translateX(calc(100% + 24px)); transition: transform 0.3s cubic-bezier(.3, .8, .3, 1);
}
body.panel-open .side-panel { transform: none; }
.tabs { display: flex; border-bottom: 1px solid var(--rule-2); background: var(--card-2); }
.tabs button {
  flex: 1; border: 0; background: none; padding: 11px 4px; cursor: pointer; font-weight: 700; font-size: 0.82rem;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; position: relative;
}
.tabs button.active { color: var(--ink); background: var(--card); box-shadow: inset 0 -3px 0 var(--red); }
.badge { position: absolute; top: 5px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font-size: 0.68rem; font-style: normal; display: grid; place-items: center; }
.tab-body { flex: 1; min-height: 0; position: relative; }
.pane { position: absolute; inset: 0; overflow-y: auto; padding: 12px 14px; display: none; }
.pane.active { display: block; }
.pane h4 { font-family: var(--display); font-size: 1rem; margin: 6px 0 8px; }
.empty-note { color: var(--ink-3); font-size: 0.88rem; font-style: italic; }

/* taccuino */
#pane-notes { padding: 10px; }
.nb-wrap {
  background: var(--paper-card); color: var(--paper-ink); border-radius: 4px; padding: 6px 4px 8px; position: relative;
  background-image: linear-gradient(90deg, transparent 31px, rgba(160, 30, 40, 0.35) 31px, rgba(160, 30, 40, 0.35) 32px, transparent 32px);
  box-shadow: inset 0 0 0 1px rgba(42, 26, 18, 0.15);
}
.notebook { width: 100%; border-collapse: collapse; font-family: var(--type); font-size: 0.84rem; }
.notebook th { font-family: var(--sans); font-size: 0.66rem; font-weight: 700; color: #6d5a45; padding: 2px 0 4px; text-transform: uppercase; }
.notebook th i { display: block; width: 10px; height: 10px; border-radius: 50%; background: var(--pc); margin: 0 auto 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); }
.notebook th.nb-env .ic { width: 16px; height: 16px; color: #8f1d24; }
.nb-sec td { font-family: var(--display); font-weight: 800; font-size: 0.9rem; color: #8f1d24; padding: 8px 4px 2px 36px; border-bottom: 1px solid rgba(42, 26, 18, 0.3); }
.notebook td.nb-card { padding: 3px 4px 3px 36px; white-space: nowrap; border-bottom: 1px solid rgba(80, 110, 160, 0.22); max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.notebook tr.struck td.nb-card { text-decoration: line-through; text-decoration-color: rgba(143, 29, 36, 0.8); text-decoration-thickness: 2px; color: #8a7a66; }
.notebook tr.suspect td.nb-card { color: #8f1d24; font-weight: bold; }
.nb-cell {
  width: 26px; min-width: 24px; height: 24px; text-align: center; cursor: pointer; border: 1px solid rgba(42, 26, 18, 0.16);
  font-family: var(--type); font-size: 1rem; line-height: 1; color: #1f3d8a; transition: background 0.1s;
}
.nb-cell:hover:not(.auto) { background: rgba(42, 26, 18, 0.08); }
.nb-cell.m-x { color: #8f1d24; }
.nb-cell.m-v { color: #1f6b3a; font-weight: bold; }
.nb-cell.m-q { color: #b07a10; }
.nb-cell.m-bang { color: #fff; background: #8f1d24; font-weight: bold; }
.nb-cell.auto { cursor: default; color: #9b8b75; background: rgba(42, 26, 18, 0.05); }
.nb-cell.auto.m-v { color: #1f6b3a; }
.nb-env { border-left: 2px solid rgba(143, 29, 36, 0.45); border-right: 2px solid rgba(143, 29, 36, 0.45); }
.nb-legend { font-size: 0.74rem; color: var(--ink-3); margin: 8px 2px 0; }
.nb-legend .ic { width: 13px; height: 13px; }
.nb-solution { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; padding: 8px 10px; margin-bottom: 8px; border-radius: 4px; background: var(--red); color: #f8efd9; }

/* indagini */
.clue { padding: 9px 10px; border-radius: 5px; background: var(--hover); margin-bottom: 8px; border-left: 3px solid var(--rule-2); }
.clue.mine { border-left-color: var(--brass); }
.clue.acc.ok { border-left-color: var(--pos); }
.clue.acc.no { border-left-color: var(--red-ink); }
.clue-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.86rem; }
.clue-head .in { color: var(--ink-3); }
.clue-trio { font-family: var(--display); font-weight: 700; margin: 3px 0 5px; }
.clue-chain { display: flex; flex-wrap: wrap; gap: 5px; }
.link { display: inline-flex; align-items: center; gap: 3px; font-size: 0.78rem; padding: 2px 6px 2px 2px; border-radius: 12px; background: var(--card-hi); border: 1px solid var(--rule); }
.link .ic { width: 13px; height: 13px; }
.link.pass .ic { color: var(--red-ink); }
.link.shown .ic { color: var(--pos); }
.link.none { padding: 2px 8px; color: var(--red-ink); font-weight: 700; }
.link .seen { font-family: var(--type); font-weight: normal; background: var(--paper-card); color: var(--paper-ink); padding: 0 5px; border-radius: 3px; }
.verdict { font-size: 0.7rem; text-transform: uppercase; font-weight: 800; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 3px; }
.verdict.ok { background: var(--pos); color: #fff; }
.verdict.no { background: var(--red); color: #fff; }
.pchip { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.pchip i { width: 10px; height: 10px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35); }

/* chat e registro */
#pane-chat.active { display: flex; flex-direction: column; padding: 0; }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 14px; user-select: text; }
.msg { margin-bottom: 7px; font-size: 0.88rem; display: grid; grid-template-columns: 1fr auto; column-gap: 8px; }
.msg .who { font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 5px; }
.msg .who::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--pc); }
.msg .who em { font-weight: 400; color: var(--ink-3); font-size: 0.78rem; }
.msg .txt { grid-column: 1 / -1; overflow-wrap: anywhere; }
.msg time { font-size: 0.7rem; color: var(--ink-3); grid-row: 1; grid-column: 2; }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--rule); }
.chat-form input { flex: 1; padding: 8px 10px; border-radius: var(--r-btn); border: 1.5px solid var(--rule-2); background: var(--card-hi); min-width: 0; }
.log-row { font-size: 0.82rem; padding: 4px 0; border-bottom: 1px dashed var(--rule); display: flex; gap: 8px; }
.log-row time { color: var(--ink-3); font-family: var(--mono); font-size: 0.72rem; padding-top: 2px; }

/* mano */
.hand { position: absolute; left: 14px; bottom: 14px; display: grid; gap: 4px; width: var(--hand-w); }
.hand-label {
  justify-self: start; display: inline-flex; align-items: center; gap: 5px; border: 0; background: rgba(10, 4, 2, 0.55); border-radius: 12px;
  padding: 2px 9px; cursor: pointer; font-family: var(--type); font-size: 0.75rem; color: #efe3c4; letter-spacing: 0.04em;
}
.hand-label:hover { background: rgba(10, 4, 2, 0.8); color: #f2dfa8; }
.hand-label .ic { width: 14px; height: 14px; }
.hand-cards { display: flex; flex-wrap: wrap; padding-right: 18px; row-gap: 0; }
.hand .hand-cards .clue-card { --w: 64px; margin-right: -18px; margin-top: -28px; transform: rotate(calc((var(--i) - (var(--n) - 1) / 2) * 3deg)); transform-origin: 50% 120%; transition: transform 0.18s, margin 0.18s; cursor: zoom-in; }
.hand-cards .clue-card:nth-child(-n+5) { margin-top: 0; }
.hand-cards .clue-card:hover { transform: translateY(-14px) rotate(0); z-index: 2; }
.hand-label.static { cursor: default; }
.hand-label.static:hover { background: rgba(10, 4, 2, 0.55); color: #efe3c4; }
.open-cards { display: flex; flex-wrap: wrap; gap: 5px; }
.card-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 16px; cursor: zoom-in;
  background: var(--paper-card); color: var(--paper-ink); border: 1px solid rgba(42, 26, 18, 0.35); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  font-family: var(--display); font-weight: 800; font-size: 0.86rem; line-height: 1.1;
}
.card-pill:hover { transform: translateY(-2px); }
.card-pill .portrait { width: 22px; height: 22px; }
.pill-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #173329; color: #e6c675; }
.card-pill.kind-room .pill-ic { background: #6a1a20; color: #f2dfa8; }
.pill-ic .ic { width: 14px; height: 14px; }

/* barra in basso */
.hud-bottom {
  position: absolute; bottom: 14px; transform: translateX(-50%);
  display: grid; justify-items: center; gap: 8px;
  /* al centro dello spazio libero tra la mano e il bordo (o il pannello) */
  --free: calc(100vw - var(--hand-w) - 28px);
  left: calc(var(--hand-w) + 14px + var(--free) / 2); max-width: calc(var(--free) - 10px);
}
body.panel-open .hud-bottom { --free: calc(100vw - var(--hand-w) - var(--panel-w) - 42px); }
.turn-info {
  background: var(--paper), var(--card); border: 1px solid var(--edge); box-shadow: var(--lift); border-radius: 20px;
  padding: 6px 16px; text-align: center; font-size: 0.9rem;
}
.turn-info:empty { display: none; }
.ti-who { display: flex; align-items: center; justify-content: center; gap: 8px; }
.ti-who i { width: 11px; height: 11px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4); }
.ti-who em { color: var(--ink-3); }
.ti-hint { font-size: 0.8rem; color: var(--ink-3); }
.timer { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font-family: var(--mono); font-size: 0.8rem; color: var(--ink-2); }
.timer.low { color: var(--red-ink); font-weight: 800; }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 8px; border-radius: 10px; background: var(--paper), var(--card); border: 1px solid var(--edge); box-shadow: var(--lift); }
.action-bar.empty { display: none; }
.action-bar.busy { opacity: 0.6; pointer-events: none; }
.ab-note { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; color: var(--ink-2); padding: 0 6px; }
.dice-readout {
  font-family: var(--serif); font-size: 1rem; color: #efe3c4; text-shadow: 0 1px 4px #000; display: flex; align-items: center; gap: 6px;
  animation: pop 0.4s cubic-bezier(.3, 1.6, .5, 1);
}
.dice-readout b { font-size: 1.3rem; color: #f2dfa8; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

/* striscia dell'ipotesi */
.suggest-strip {
  position: absolute; top: 66px; left: 50%; transform: translateX(-50%); z-index: 6;
  background: var(--paper), var(--card); border: 1px solid var(--edge); box-shadow: var(--lift); border-radius: 10px;
  padding: 10px 14px 12px; display: grid; justify-items: center; gap: 7px; min-width: 300px; max-width: calc(100vw - 520px);
  animation: stripIn 0.35s cubic-bezier(.2, .9, .3, 1.2);
}
body.panel-open .suggest-strip { left: max(calc((100vw - var(--panel-w) - 14px) / 2), 420px); }
.suggest-strip.out { opacity: 0; transform: translate(-50%, -14px); transition: opacity 0.3s, transform 0.3s; }
@keyframes stripIn { from { opacity: 0; transform: translate(-50%, -20px); } }
.ss-head { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.ss-head i { width: 11px; height: 11px; border-radius: 50%; background: var(--pc); }
.ss-cards { display: flex; gap: 8px; }
.ss-cards .clue-card.xs { --w: 80px; }
.ss-chain { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.sl { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 600; padding: 2px 8px 2px 4px; border-radius: 12px; background: var(--hover); border: 1px solid var(--rule); }
.sl i { width: 9px; height: 9px; border-radius: 50%; background: var(--pc); }
.sl em { font-style: normal; font-weight: 700; font-size: 0.7rem; text-transform: uppercase; }
.sl.wait { opacity: 0.5; }
.sl.pass em { color: var(--red-ink); }
.sl.shown { background: var(--pos); color: #fff; border-color: transparent; }
.sl.thinking { box-shadow: 0 0 0 2px var(--brass-hi); animation: think 1s ease-in-out infinite; }
@keyframes think { 50% { box-shadow: 0 0 0 4px transparent; } }
.ss-result { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.ss-result.none { color: var(--red-ink); font-family: var(--display); font-size: 1.1rem; font-weight: 800; }

/* ---------- carte indizio ---------- */
.clue-card {
  --w: 110px; --sc: #6d5a45;
  width: var(--w); aspect-ratio: 5 / 7; flex: none; position: relative; display: flex; flex-direction: column;
  border-radius: calc(var(--w) * 0.07); background: var(--paper-card); color: var(--paper-ink);
  border: 1px solid rgba(42, 26, 18, 0.35); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  padding: calc(var(--w) * 0.05); overflow: hidden; font-size: calc(var(--w) * 0.1);
}
.clue-card.xs { --w: 62px; }
.clue-card.sm { --w: 76px; }
.clue-card.md { --w: 124px; }
.clue-card.lg { --w: 190px; }
.cc-kind { font-family: var(--type); font-size: 0.62em; text-transform: uppercase; letter-spacing: 0.08em; text-align: center; color: #7a6650; line-height: 1.3; }
.clue-card .art { flex: 1; min-height: 0; width: 100%; border-radius: calc(var(--w) * 0.035); margin: calc(var(--w) * 0.03) 0; display: grid; place-items: center; overflow: hidden; }
.clue-card svg.art { height: auto; aspect-ratio: auto; object-fit: cover; }
.kind-suspect { border-top: calc(var(--w) * 0.04) solid var(--sc); }
.kind-suspect .art { border: 1px solid rgba(0, 0, 0, 0.25); }
.weapon-art { background: radial-gradient(circle at 50% 40%, #2f5a48, #173329); color: #e6c675; }
.weapon-art .ic { width: 62%; height: 62%; stroke-width: 1.3; }
.room-art { background: radial-gradient(circle at 50% 40%, #8a2a2f, #4c1014); color: #f2dfa8; }
.room-art .ic { width: 52%; height: 52%; stroke-width: 1.3; }
.room-kitchen { background: repeating-conic-gradient(#2b2a2c 0 25%, #e9e2d0 0 50%) 50% / 20% 20%; color: #8f1d24; }
.room-ballroom { background: linear-gradient(135deg, #c08a52, #8a5a2c); }
.room-conservatory { background: radial-gradient(circle, #6f8f5a, #2f4d2a); }
.room-dining { background: linear-gradient(#6e3d22, #3e2112); }
.room-billiard { background: radial-gradient(circle, #2e7a58, #134030); }
.room-library { background: radial-gradient(circle, #8a2a2f, #4c1014); }
.room-lounge { background: radial-gradient(circle, #6b3558, #331528); }
.room-hall { background: repeating-conic-gradient(#8f8a80 0 25%, #e6dfcf 0 50%) 50% / 24% 24%; color: #2a1a12; }
.room-study { background: linear-gradient(#4a2c1c, #24140c); }
.room-kitchen .ic, .room-hall .ic { background: rgba(243, 233, 210, 0.85); border-radius: 50%; padding: 6%; }
.cc-name { font-family: var(--display); font-weight: 800; text-align: center; font-size: max(0.86em, 9px); line-height: 1.1; min-height: 2.2em; display: grid; place-items: center; }
.clue-card.xs .cc-kind { display: none; }
.clue-card.xs .cc-name { font-size: max(0.95em, 9px); min-height: 2.2em; }
.clue-card.back { background: repeating-linear-gradient(45deg, #7a1a1f 0 6px, #6a1419 6px 12px); border: 2px solid #c9a54a; display: grid; place-items: center; }
.seal { width: 42%; aspect-ratio: 1; border-radius: 50%; background: #c9a54a; color: #5e1015; display: grid; place-items: center; font-family: var(--display); font-weight: 900; font-size: 2em; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }

.flip { perspective: 900px; }
.flip-in { position: relative; transform-style: preserve-3d; transition: transform 0.7s cubic-bezier(.3, .8, .3, 1.1); transition-delay: calc(var(--d, 0) * 0.05s); }
.flip-in > .clue-card { backface-visibility: hidden; }
.flip-in > .face { position: absolute; inset: 0; transform: rotateY(180deg); }
.flip.on .flip-in { transform: rotateY(180deg); }

/* ---------- modali ---------- */
#modals { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.modal-wrap {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; pointer-events: auto;
  background: rgba(10, 4, 2, 0.55); backdrop-filter: blur(2px); animation: fade 0.2s;
}
.modal-wrap.out { opacity: 0; transition: opacity 0.18s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px 22px; animation: dealIn 0.35s cubic-bezier(.2, .9, .3, 1.1); }
.modal.wide { width: min(720px, 100%); }
.modal.narrow { width: min(340px, 100%); }
.modal h2 { font-family: var(--display); font-size: 1.45rem; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.modal h4 { font-family: var(--display); margin: 14px 0 8px; font-size: 1rem; }
.modal .lead { margin: 0 0 8px; color: var(--ink-2); }
.modal .fine { font-size: 0.82rem; color: var(--ink-3); text-align: center; }
.danger-title { color: var(--red-ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal.dark { background: radial-gradient(circle at 50% 0%, #4a1216, #160807); color: #efe3c4; border-color: #000; }

.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px 8px; }
.pick { position: relative; display: grid; justify-items: center; align-content: start; gap: 4px; cursor: pointer; }
/* carte del selettore più grandi, nome su due righe ben leggibile */
.pick .clue-card.xs { --w: 88px; }
.pick .clue-card .cc-name, .ss-cards .clue-card .cc-name { font-size: 11.5px; line-height: 1.12; min-height: 2.3em; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick .clue-card { transition: transform 0.12s, box-shadow 0.12s; }
.pick:hover .clue-card { transform: translateY(-3px); }
.pick input:checked + .clue-card { box-shadow: 0 0 0 3px var(--red), 0 6px 14px rgba(0, 0, 0, 0.4); transform: translateY(-4px); }
.pick input:focus-visible + .clue-card { outline: 2px solid var(--brass-hi); outline-offset: 2px; }
.pick-hint { font-size: 0.7rem; font-weight: 700; padding: 0 5px; border-radius: 3px; background: var(--solid); color: var(--on-solid); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-hint.sus { background: var(--red); color: #fff; }
.pick:has(.pick-hint.known) .clue-card { opacity: 0.55; }

.refute-cards { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.refute-opt { border: 0; background: none; padding: 0; cursor: pointer; transition: transform 0.15s; }
.refute-opt:hover:not(:disabled) { transform: translateY(-6px) rotate(-1deg); }
.refute-opt { display: grid; justify-items: center; gap: 6px; }
.refute-opt .clue-card { --w: 130px; }
.refute-opt.have .clue-card { box-shadow: 0 0 0 3px var(--brass-hi), 0 8px 18px rgba(0, 0, 0, 0.45); }
.refute-opt.miss { cursor: default; }
.refute-opt.miss .clue-card { opacity: 0.38; filter: grayscale(0.7); }
.refute-opt:disabled:hover { transform: none; }
.ro-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.refute-opt.have .ro-tag { color: var(--brass-hi); }
.ro-tag .ic { width: 14px; height: 14px; }
.refute-hint { margin: 0 0 4px; padding: 8px 10px; border-radius: 5px; background: var(--hover); border-left: 3px solid var(--brass); font-size: 0.9rem; }
.refute-hint.none { border-left-color: var(--red-ink); }
.refute-mine { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--rule-2); }
.refute-mine > span { font-family: var(--type); font-size: 0.75rem; color: var(--ink-3); margin-right: 4px; }
.refute-mine .clue-card.hot { box-shadow: 0 0 0 2px var(--brass-hi); }

.reveal { text-align: center; display: grid; justify-items: center; gap: 10px; }
.zoom { display: grid; place-items: center; }
.accusation, .over { text-align: center; display: grid; justify-items: center; gap: 10px; }
.acc-kicker { display: inline-flex; align-items: center; gap: 6px; font-family: var(--type); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.8rem; opacity: 0.8; }
.accusation h2, .over h2 { justify-content: center; font-size: 1.8rem; }
.acc-cards, .sol-cards, .deal { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 6px 0; }
.acc-verdict { min-height: 44px; font-family: var(--display); font-size: 1.8rem; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.acc-verdict.ok { color: #9be0b4; animation: pop 0.4s; }
.acc-verdict.no { color: #ff8e84; animation: pop 0.4s; }
.sol-line { margin: 0; }
.hands { width: 100%; text-align: left; font-size: 0.86rem; }
.hands summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.hand-row { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--rule); }
.hand-row span:last-child { color: var(--ink-2); }
.dealt { animation: dealCard 0.5s cubic-bezier(.2, .9, .3, 1.2) both; animation-delay: calc(var(--i) * 0.12s); }
@keyframes dealCard { from { opacity: 0; transform: translateY(-40px) rotate(-12deg); } }
.help { font-size: 0.92rem; }
.help ol, .help ul { padding-left: 20px; }
.help li { margin-bottom: 6px; }
.keys { font-size: 0.82rem; color: var(--ink-3); }
kbd { font-family: var(--mono); font-size: 0.78rem; padding: 1px 6px; border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 3px; }

/* ---------- banner, toast, tooltip ---------- */
#banner-root { position: fixed; inset: 0; pointer-events: none; z-index: 30; display: grid; place-items: center; }
.banner {
  --bc: #7a1a1f;
  font-family: var(--display); font-weight: 900; font-size: clamp(28px, 5vw, 54px); color: #f8efd9; text-align: center;
  padding: 14px 44px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--bc) 85%, #000) 18%, color-mix(in srgb, var(--bc) 85%, #000) 82%, transparent);
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.55); animation: bannerIn 1.9s ease both; width: 100%;
  display: grid; justify-items: center;
}
.banner small { font-family: var(--type); font-weight: 400; font-size: 0.32em; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.9; }
@keyframes bannerIn {
  0% { opacity: 0; transform: scaleY(0.2); }
  12% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-12px); }
}
#toasts { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; z-index: 50; pointer-events: none; }
.toast { background: var(--solid); color: var(--on-solid); padding: 8px 14px; border-radius: 6px; font-size: 0.88rem; box-shadow: var(--lift); animation: toast 3.4s ease both; max-width: 90vw; text-align: center; }
.toast.error { background: var(--red); color: #fff; }
.toast.ok { background: #2a6046; color: #fff; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.board-tip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--solid); color: var(--on-solid); border-radius: 5px;
  padding: 6px 10px; font-size: 0.85rem; display: grid; max-width: 260px; box-shadow: var(--lift);
}
.board-tip b { font-family: var(--display); }
.board-tip small { opacity: 0.8; }
.board-tip small.go { color: var(--brass-hi); opacity: 1; font-weight: 700; }
#conn-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 90; background: var(--red); color: #fff; text-align: center; padding: 8px; font-weight: 600; display: flex; justify-content: center; gap: 10px; align-items: center; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#fps { position: fixed; left: 50%; top: 4px; transform: translateX(-50%); z-index: 60; font-family: var(--mono); font-size: 0.75rem; color: #9be0b4; background: rgba(0, 0, 0, 0.6); padding: 1px 6px; border-radius: 3px; }

/* ---------- popover audio e grafica ---------- */
.audio-fab, .gfx-fab { position: fixed; bottom: 14px; z-index: 15; }
.audio-fab { right: 14px; }
.gfx-fab { right: 62px; }
body.in-game .audio-fab, body.in-game .gfx-fab { display: none; }
.audio-pop, .gfx-pop { position: fixed; z-index: 70; padding: 12px; display: grid; gap: 10px; width: 250px; }
.ap-row { display: flex; align-items: center; gap: 10px; }
.ap-toggle { display: flex; align-items: center; gap: 6px; border: 1px solid var(--rule-2); background: none; border-radius: 4px; padding: 5px 8px; cursor: pointer; width: 104px; font-size: 0.85rem; font-weight: 600; }
.ap-toggle[aria-pressed="false"] { opacity: 0.5; text-decoration: line-through; }
.ap-row input[type="range"] { flex: 1; accent-color: var(--red); }
.gp-title { font-family: var(--display); font-weight: 800; }
.gp-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.88rem; }
.gp-row select { padding: 4px 6px; border-radius: 4px; border: 1px solid var(--rule-2); background: var(--card-hi); }
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.88rem; }
.toggle input { position: absolute; opacity: 0; }
.toggle span { width: 34px; height: 19px; border-radius: 10px; background: var(--rule-2); position: relative; transition: background 0.15s; flex: none; }
.toggle span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle input:checked + span { background: var(--red); }
.toggle input:checked + span::after { transform: translateX(15px); }

/* ---------- spettatori ---------- */
body.spectating #hand, body.spectating #btn-hand { display: none; }

/* ---------- schermi stretti ---------- */
@media (max-width: 900px) {
  :root { --panel-w: 100vw; }
  .lobby-body { grid-template-columns: 1fr; }
  .side-panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 62vh; border-radius: 12px 12px 0 0; transform: translateY(105%); }
  body.panel-open .side-panel { transform: none; }
  body.panel-open .hud-tools { right: 14px; }
  body.panel-open .hud-bottom, body.panel-open .suggest-strip { left: 50%; }
  body.panel-open .hud-bottom { display: none; }
  .hud-players { width: auto; right: 14px; top: 62px; display: flex; overflow-x: auto; max-height: none; padding-bottom: 4px; }
  .pl { flex: none; padding-right: 8px; }
  .pl-body { display: none; }
  .pl.cur { transform: translateY(3px); }
  .hud-tools { left: 14px; right: 14px; justify-content: flex-end; }
  .hand { left: 8px; right: 8px; bottom: auto; top: 112px; width: auto; }
  .hand-label { display: none; }
  .open-cards { display: none; }     /* su telefono si vedono dal pulsante delle carte */
  .hand-cards { flex-wrap: nowrap; }
  .hand .hand-cards .clue-card { --w: 50px; margin-right: -10px; margin-top: 0; }
  .hud-bottom, body.panel-open .hud-bottom { left: 50%; max-width: calc(100vw - 20px); }
  .hand-cards .clue-card .cc-kind { display: none; }
  .suggest-strip { top: auto; bottom: 150px; max-width: calc(100vw - 20px); min-width: 0; }
  #toasts { bottom: 180px; }
  .icon-btn { width: 36px; height: 36px; }
}
@media (max-width: 520px) {
  .suspect-picker { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .so-name { font-size: 0.74rem; }
  .lobby-foot { flex-wrap: wrap; }
  .lobby-foot .hint { order: 3; flex-basis: 100%; text-align: center; }
  .action-bar .btn { padding: 7px 10px; font-size: 0.84rem; }
  .modal { padding: 16px; }
  .picker { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
  .pick .clue-card.xs { --w: 76px; }
  .pick .clue-card .cc-name { font-size: 10.5px; }
  .ss-cards .clue-card.xs { --w: 66px; }
  .ss-cards .clue-card .cc-name { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
