/* Codenames: interfaccia "sul tavolo" adattata dallo stile grafico di Monopoly.
   Cartoncino caldo, inchiostro scuro, rosso scarlatto, blu Prussia, ottone e tavolo in noce. */

:root {
  --card: #f2e9d0;
  --card-hi: #faf4e2;
  --card-2: #e4d7b4;
  --ink: #1f2a24;
  --ink-2: #434a41;
  --ink-3: #686d61;
  --rule: rgba(31, 42, 36, 0.2);
  --rule-2: rgba(31, 42, 36, 0.38);

  --red: #a8202a;
  --red-dk: #7f141c;
  --red-soft: rgba(168, 32, 42, 0.14);
  --blue: #24527a;
  --blue-dk: #173855;
  --blue-soft: rgba(36, 82, 122, 0.14);
  --neutral-card: #c7b48f;
  --neutral-dk: #9a8560;
  --assassin: #1f2224;
  --assassin-dk: #0f1112;

  --green: #2e5b45;
  --green-dk: #1f4232;
  --brass: #a9802f;
  --brass-hi: #d6ad57;
  --wood: #2a1a12;
  --pos: #2e7a50;
  --neg: #a8202a;

  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --sans: 'Libre Franklin', 'Franklin Gothic', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --cond: 'Barlow Condensed', 'Arial Narrow', 'Libre Franklin', sans-serif;

  --r-card: 6px;
  --r-btn: 4px;
  --lift: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 2px 3px rgba(25, 12, 6, 0.28), 0 14px 30px -10px rgba(25, 12, 6, 0.6);
  --paper: linear-gradient(transparent, transparent); /* popolato all'avvio da paperGrain() */

  --red-ink: var(--red);
  --blue-ink: var(--blue);
  --green-ink: var(--green);
  --on-accent: #faf4e2;
  --solid: #1f2a24;
  --on-solid: #faf4e2;
  --solid-bd: #0f1612;
  --edge: rgba(31, 42, 36, 0.28);
  --hover: rgba(31, 42, 36, 0.07);
  --cream: #f2e9d0;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --card: #27231e;
  --card-hi: #312c26;
  --card-2: #3a342c;
  --ink: #ede5d0;
  --ink-2: #bdb39c;
  --ink-3: #918a78;
  --rule: rgba(237, 229, 208, 0.14);
  --rule-2: rgba(237, 229, 208, 0.3);

  --red: #b92d37;
  --red-dk: #8a1a22;
  --red-soft: rgba(185, 45, 55, 0.22);
  --blue: #2e6799;
  --blue-dk: #1b4469;
  --blue-soft: rgba(46, 103, 153, 0.24);
  --green: #2f6b4f;
  --green-dk: #1f4a37;
  --pos: #74c597;
  --neg: #f07a76;
  --red-ink: #f07a76;
  --blue-ink: #7bb4e6;
  --green-ink: #74c597;
  --brass: #c49a45;
  --solid: #e6dcc0;
  --on-solid: #1d1a16;
  --solid-bd: #bfb498;
  --edge: rgba(0, 0, 0, 0.55);
  --hover: rgba(237, 229, 208, 0.08);
  --lift: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 2px 3px rgba(0, 0, 0, 0.45), 0 14px 30px -10px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}
:root[data-theme="dark"] body { background: #1b120c; }
:root[data-theme="dark"] .code { color: var(--red-ink); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--wood);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  font-variant-numeric: lining-nums;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { user-select: text; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.theme-anim, .theme-anim * { transition: background-color 0.25s, color 0.25s, border-color 0.25s !important; }

#table-bg { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 76% 70% at 50% 45%, transparent 48%, rgba(16, 8, 3, 0.62) 100%);
}

/* ---------- materiali ---------- */
.card {
  background: var(--paper), var(--card);
  border: 1px solid var(--edge);
  border-radius: var(--r-card);
  box-shadow: var(--lift);
}

.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }

.wordmark {
  font-family: var(--sans);
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0;
  line-height: 1;
}

/* ---------- pulsanti ---------- */
.btn {
  --bg: transparent; --fg: var(--ink); --bd: var(--ink);
  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.93rem; 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, box-shadow 0.08s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background-color: color-mix(in srgb, var(--bg) 88%, #000); }
.btn:not(.primary, .green, .gold, .blue, .team-red-btn, .team-blue-btn):hover:not(:disabled) { background-color: var(--hover); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { --bg: var(--red); --fg: var(--on-accent); --bd: var(--red-dk); }
.btn.team-red-btn { --bg: var(--red); --fg: var(--on-accent); --bd: var(--red-dk); }
.btn.team-blue-btn { --bg: var(--blue); --fg: var(--on-accent); --bd: var(--blue-dk); }
.btn.green { --bg: var(--green); --fg: var(--on-accent); --bd: var(--green-dk); }
.btn.gold { --bg: var(--brass); --fg: #1d160a; --bd: #82611f; }
.btn.blue { --bg: var(--solid); --fg: var(--on-solid); --bd: var(--solid-bd); }
.btn.ghost { --bd: var(--rule-2); box-shadow: none; }
.btn.big { padding: 12px 22px; font-size: 1.02rem; }
.btn.small { padding: 5px 11px; font-size: 0.84rem; }
.btn.tiny { padding: 3px 8px; font-size: 0.78rem; border-width: 1px; box-shadow: none; gap: 4px; }
.btn.pulse { animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { box-shadow: inset 0 -2px 0 rgba(0,0,0,0.14), 0 0 0 0 rgba(169, 128, 47, 0); }
  50% { box-shadow: inset 0 -2px 0 rgba(0,0,0,0.14), 0 0 0 5px rgba(169, 128, 47, 0.38); }
}

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-btn); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper), var(--card); color: var(--ink);
  border: 1px solid var(--edge); box-shadow: var(--lift);
  font-size: 1.1rem; transition: transform 0.12s, background-color 0.15s;
}
.icon-btn:hover { background-color: var(--card-hi); transform: translateY(-1px); }
.icon-btn.off { color: var(--ink-3); }
.icon-btn.off .ic { opacity: 0.5; }
.icon-btn.danger:hover { color: var(--red-ink); }
.icon-btn.on { background: var(--solid); color: var(--on-solid); border-color: var(--solid-bd); }
.icon-btn.on:hover { background: var(--solid); }

/* ---------- campi & toggle ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin: 12px 0; }
.field > span, .sub-label { font-size: 0.84rem; color: var(--ink-2); font-weight: 600; }
.sub-label { margin: 12px 0 6px; }
.field input, .field select, .field textarea, .join-row input, .chat-form input, .clue-input {
  background: var(--card-hi);
  border: 1.5px solid var(--rule-2);
  border-radius: var(--r-btn); padding: 10px 12px; outline: none; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; font-family: var(--mono); font-size: 0.82rem; line-height: 1.4; }
.field input::placeholder, .field textarea::placeholder, .join-row input::placeholder, .chat-form input::placeholder, .clue-input::placeholder {
  color: var(--ink-3);
}
.field input:focus, .field select:focus, .field textarea:focus, .join-row input:focus, .chat-form input:focus, .clue-input:focus {
  border-color: var(--ink); box-shadow: 0 0 0 3px rgba(169, 128, 47, 0.3);
}
.field.compact { margin: 6px 0 11px; }
.field.compact input, .field.compact select { padding: 8px 10px; }
.field select:disabled, .field textarea:disabled, .toggle input:disabled ~ * { opacity: 0.55; }
.field-meta { font-size: 0.78rem; color: var(--ink-2); }
select option { background: var(--card-hi); color: var(--ink); }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toggle { display: flex; align-items: flex-start; gap: 10px; margin: 11px 0; cursor: pointer; font-size: 0.9rem; line-height: 1.3; }
.toggle .tl { padding-top: 1px; }
.toggle .tl small { display: block; font-size: 0.8rem; color: var(--ink-2); margin-top: 2px; line-height: 1.35; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle input + span {
  width: 38px; height: 22px; border-radius: 22px; background: var(--card-2); position: relative; flex: none;
  border: 1.5px solid var(--rule-2); transition: background-color 0.2s, border-color 0.2s;
}
.toggle input + span::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--card-hi); box-shadow: 0 1px 2px rgba(0,0,0,0.35); transition: transform 0.2s;
}
.toggle input:checked + span { background: var(--green); border-color: var(--green-dk); }
.toggle input:checked + span::after { transform: translateX(16px); }
.toggle input:focus-visible + span { outline: 2px solid var(--brass); outline-offset: 2px; }
input[type=range] { accent-color: var(--ink); }

.count { font-family: var(--sans); font-weight: 500; font-size: 0.82rem; color: var(--ink-2); margin-left: 6px; }

/* ---------- caricamento ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(ellipse at 50% 40%, #3b261a, var(--wood) 70%);
  transition: opacity 0.55s;
}
#loader.done { opacity: 0; pointer-events: none; }
.loader-mark {
  font-size: clamp(2rem, 7.5vw, 3.8rem); color: var(--on-accent); background: var(--red);
  padding: 14px 28px 12px 34px; border-radius: 3px;
  box-shadow: inset 0 0 0 3px var(--red), inset 0 0 0 5px var(--card), 0 20px 50px rgba(0,0,0,0.5);
}
.loader-bar { width: 200px; height: 2px; background: rgba(242, 233, 208, 0.15); overflow: hidden; }
.loader-bar span { display: block; height: 100%; width: 35%; background: var(--card); animation: load 1.3s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.loader-text { color: rgba(242, 233, 208, 0.68); font-size: 0.9rem; font-style: italic; font-family: var(--serif); }

/* ---------- schermate ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; overflow-y: auto; }

/* home: coperchio della scatola appoggiato sul tavolo (come Monopoly) */
#home { justify-content: flex-start; padding-left: max(16px, 7vw); }
.home-card { width: min(410px, 100%); overflow: hidden; }
.lid {
  background: var(--red); padding: 20px 22px 22px; position: relative; text-align: center;
  box-shadow: inset 0 0 0 6px var(--red), inset 0 0 0 7.5px rgba(242, 233, 208, 0.85);
}
.lid-kicker {
  font-family: var(--serif); font-style: italic; font-size: 0.78rem; letter-spacing: 0.22em;
  color: rgba(250, 244, 226, 0.84); margin-bottom: 6px;
}
.lid .wordmark { color: var(--on-accent); font-size: clamp(2.1rem, 8.2vw, 2.85rem); text-align: center; padding-left: 0.12em; }
.home-body { padding: 18px 26px 22px; }
.tagline { font-family: var(--serif); font-style: italic; font-size: 1.08rem; margin: 0 0 8px; color: var(--ink); }
.home-card .btn.big { width: 100%; margin-top: 4px; }
.join { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--rule); }
.join .field { margin-bottom: 6px; }
.join-row { display: flex; gap: 8px; }
.join-row input {
  flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 0.28em; text-align: center;
  font-family: var(--mono); font-weight: 700; font-size: 1.3rem; padding: 8px 10px;
}
.join-row input::placeholder { letter-spacing: 0.28em; opacity: 0.4; }
.fineprint { color: var(--ink-2); font-size: 0.8rem; margin: 18px 0 0; line-height: 1.45; }

.deal-in { animation: dealIn 0.65s cubic-bezier(0.2, 0.9, 0.25, 1) both; }
@keyframes dealIn { from { opacity: 0; transform: translateY(22px) rotate(-1deg); } to { opacity: 1; transform: none; } }

/* ---------- lobby ---------- */
.lobby-card { width: min(1120px, 100%); padding: 22px 26px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.lobby-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.ticket-label { font-size: 0.84rem; color: var(--ink-2); font-weight: 600; }
.code {
  font-family: var(--mono); font-size: 2.5rem; font-weight: 800; letter-spacing: 0.16em; color: var(--red-dk); line-height: 1.1; user-select: all;
  display: inline-block; margin-top: 4px; padding: 2px 6px 2px 14px; border-radius: var(--r-btn); background: var(--card-hi); border: 1.5px dashed var(--rule-2);
}
.lobby-share { display: flex; gap: 8px; flex-wrap: wrap; }

.lobby-body { display: grid; grid-template-columns: 1.45fr 0.85fr 1fr; gap: 26px; padding: 16px 0; overflow-y: auto; }
.lobby-col { min-width: 0; }
.lobby-col h3, .modal h2, .help h3 { font-family: var(--serif); font-weight: 700; }
.lobby-col h3 { font-size: 1.18rem; margin: 2px 0 10px; display: flex; align-items: baseline; }
.col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.col-head h3 { margin: 0; }

.team-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.team-box {
  background: var(--card-2); border-radius: var(--r-btn); padding: 10px;
  border-top: 5px solid var(--tc); display: flex; flex-direction: column; gap: 10px;
}
.team-box.team-red { --tc: var(--red); }
.team-box.team-blue { --tc: var(--blue); }
.team-box-head { display: flex; align-items: center; gap: 7px; font-family: var(--serif); font-size: 1.05rem; }
.team-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tc); flex: none; }

.role-block { display: flex; flex-direction: column; gap: 5px; }
.role-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.role-label { font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }

.roster-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.roster-list li {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: var(--r-btn);
  background: var(--card-hi); border: 1px solid var(--rule); font-size: 0.88rem;
}
.roster-list li.empty {
  background: transparent; border: 1px dashed var(--rule); color: var(--ink-3);
  font-style: italic; font-family: var(--serif); justify-content: center; padding: 7px; font-size: 0.84rem;
}
.roster-list .p-ic { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); flex: none; }
.roster-list .nm { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-list .crown { color: var(--brass); display: inline-flex; }
.roster-list .you { font-size: 0.76rem; color: var(--ink-2); font-weight: 500; }
.roster-list .kick-btn { border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 2px; display: inline-flex; border-radius: 3px; }
.roster-list .kick-btn:hover { color: var(--red-ink); background: var(--hover); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); flex: none; }
.dot.off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }

.unassigned-wrap { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--rule); display: flex; flex-direction: column; gap: 6px; }
.unassigned-wrap .roster-list { flex-direction: row; flex-wrap: wrap; }
.unassigned-wrap .roster-list li { flex: 0 1 auto; }

.badge-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.badge-opt {
  border: 1.5px solid transparent; border-radius: var(--r-btn); background: var(--card-2); cursor: pointer;
  padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 0.74rem; color: var(--ink-2); transition: background-color 0.15s, border-color 0.15s;
}
.badge-opt .ic { width: 24px; height: 24px; color: var(--ink); }
.badge-opt:hover { background: var(--card-hi); }
.badge-opt.sel { border-color: var(--ink); background: var(--card-hi); color: var(--ink); font-weight: 700; }

.host-note { font-size: 0.85rem; color: var(--ink-2); margin: -4px 0 8px; font-style: italic; font-family: var(--serif); }
.lobby-foot { display: flex; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px solid var(--rule); }
.lobby-foot .hint { flex: 1; text-align: center; color: var(--ink-2); font-size: 0.9rem; }

/* ---------- TAVOLO DI GIOCO ---------- */
#game {
  position: fixed; inset: 0; z-index: 5;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  gap: 8px;
}

.game-top {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(260px, 1.35fr) minmax(210px, 1fr);
  align-items: start;
  gap: 10px;
  z-index: 12;
}

.team-hud {
  display: flex; align-items: center; gap: 10px; padding: 6px 11px;
  border-top: 4px solid var(--tc); transition: transform 0.25s, box-shadow 0.25s;
  min-width: 0;
}
.team-hud-red { --tc: var(--red); justify-self: start; max-width: 310px; width: 100%; }
.team-hud-blue { --tc: var(--blue); max-width: 310px; width: 100%; }
.team-hud.active { box-shadow: 0 0 0 2px var(--brass), var(--lift); transform: translateY(1px); }

.th-score {
  font-family: var(--serif); font-weight: 800; font-size: 2rem; line-height: 1;
  min-width: 44px; height: 44px; border-radius: var(--r-btn);
  background: var(--tc); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22);
}
.th-info { min-width: 0; flex: 1; }
.th-info-right { text-align: right; }
.th-title { font-family: var(--serif); font-weight: 700; font-size: 0.96rem; display: flex; align-items: center; gap: 5px; }
.th-info-right .th-title { justify-content: flex-end; }
.start-pip { color: var(--brass); font-size: 0.9rem; }
.th-roster { display: flex; flex-wrap: wrap; gap: 3px 6px; margin-top: 2px; font-size: 0.76rem; color: var(--ink-2); }
.th-info-right .th-roster { justify-content: flex-end; }
.th-member { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.th-member.spy { font-weight: 700; color: var(--ink); }
.th-member.off { opacity: 0.45; }
.th-member .spy-tag {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--card-2); border: 1px solid var(--rule); border-radius: 3px; padding: 0 4px;
}

.top-right-group { display: flex; align-items: flex-start; justify-content: flex-end; gap: 8px; }
.hud-tools { display: flex; gap: 6px; flex: none; }

.turn-center { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.turn-info {
  font-size: 0.92rem; text-align: center; padding: 6px 15px;
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
  border-bottom: 3px solid var(--tc, var(--brass));
}
.turn-info.red { --tc: var(--red); }
.turn-info.blue { --tc: var(--blue); }
.turn-info .who-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tc, var(--brass)); flex: none; }
.turn-info .yours { color: var(--tc, var(--red-ink)); font-family: var(--serif); font-weight: 700; font-size: 1.02rem; }
.turn-info .timer {
  font-family: var(--mono); font-weight: 700; font-size: 0.9rem;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 3px; background: var(--card-2);
}
.turn-info .timer.low { background: var(--red); color: var(--on-accent); }

.active-clue-bar {
  display: inline-flex; align-items: center; gap: 10px; padding: 5px 14px;
  background: var(--paper), var(--card-hi);
  animation: dealIn 0.35s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
.clue-word {
  font-family: var(--cond); font-weight: 800; font-size: 1.5rem; letter-spacing: 0.07em;
  line-height: 1; text-transform: uppercase;
}
.clue-num {
  font-family: var(--serif); font-weight: 800; font-size: 1.25rem; line-height: 1;
  min-width: 30px; height: 30px; padding: 0 7px; border-radius: var(--r-btn);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tc, var(--ink)); color: var(--on-accent);
}
.clue-meta { font-size: 0.8rem; color: var(--ink-2); font-weight: 600; }

/* ---------- GRIGLIA 5×5 CODENAMES ---------- */
.board-stage {
  min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 4px 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: clamp(7px, 1.1vw, 13px);
  width: min(1040px, 100%);
  height: min(100%, 640px);
  max-height: 100%;
  perspective: 1400px;
}

.cn-card {
  position: relative;
  width: 100%; height: 100%;
  min-height: 0;
  border: 0; padding: 0; background: none;
  cursor: default;
  transform-style: preserve-3d;
  transition: transform 0.16s ease;
  outline: none;
}
.cn-card.interactive { cursor: pointer; }
.cn-card.interactive:not(.revealed):hover { transform: translateY(-3px); }
.cn-card.interactive:not(.revealed):hover .cn-front {
  box-shadow: 0 1px 0 rgba(255,255,255,0.75) inset, 0 8px 18px rgba(15, 7, 3, 0.45);
}

.cn-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.62s cubic-bezier(0.22, 0.9, 0.28, 1);
}
.cn-card.revealed .cn-inner { transform: rotateY(180deg); }

.cn-face {
  position: absolute; inset: 0;
  border-radius: var(--r-card);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden;
}

/* Fronte carta (cartoncino dossier chiaro, anche in tema scuro rimane oggetto fisico sul tavolo) */
.cn-front {
  background: var(--paper), #f7f0dc;
  color: #1f2a24;
  border: 1.5px solid rgba(31, 42, 36, 0.25);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset, 0 3px 6px rgba(18, 9, 4, 0.32), 0 10px 20px -10px rgba(18, 9, 4, 0.55);
  padding: 6px 7px;
}
.cn-front::before {
  content: ''; position: absolute; inset: 4px;
  border: 1px solid rgba(31, 42, 36, 0.14); border-radius: 3px; pointer-events: none;
}

.cn-head {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  min-height: 18px; position: relative; z-index: 2;
}
.cn-serial {
  font-family: var(--mono); font-size: 0.64rem; font-weight: 700; letter-spacing: 0.06em;
  color: rgba(31, 42, 36, 0.44); padding-left: 2px;
}
.cn-key-pill {
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 3px; color: #faf4e2; line-height: 1.3;
  display: inline-flex; align-items: center; gap: 3px;
}
.cn-key-pill .ic { width: 11px; height: 11px; }

.cn-word-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 2px 4px; position: relative; z-index: 2;
}
.cn-word {
  font-family: var(--cond); font-weight: 800;
  font-size: clamp(0.98rem, 1.75vw, 1.48rem);
  letter-spacing: 0.04em; line-height: 1.05; text-align: center;
  text-transform: uppercase; color: #1a231e;
  background: rgba(255, 252, 242, 0.88);
  border: 1px solid rgba(31, 42, 36, 0.13);
  border-radius: 3px;
  padding: 5px 8px;
  width: 100%;
  overflow-wrap: anywhere;
}
:root[data-card-size="large"] .cn-word {
  font-size: clamp(1.12rem, 2.05vw, 1.72rem);
}

.cn-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  min-height: 20px; position: relative; z-index: 3;
}
.cn-marks { display: flex; flex-wrap: wrap; gap: 3px; flex: 1; min-width: 0; }
.cn-mark-pill {
  font-size: 0.66rem; font-weight: 700; padding: 1px 5px; border-radius: 3px;
  background: var(--brass); color: #1d160a; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cn-mark-pill.mine { background: #1f2a24; color: #faf4e2; }

.cn-reveal-btn {
  display: inline-flex; align-items: center; gap: 3px;
  border: 1.5px solid var(--green-dk); border-radius: 3px;
  background: var(--green); color: var(--on-accent);
  font-size: 0.7rem; font-weight: 700; padding: 2px 7px; cursor: pointer;
  opacity: 0; transform: scale(0.92);
  transition: opacity 0.14s, transform 0.14s, background-color 0.14s;
  flex: none;
}
.cn-reveal-btn .ic { width: 12px; height: 12px; }
.cn-card.interactive:hover .cn-reveal-btn,
.cn-card.interactive:focus-within .cn-reveal-btn,
.cn-card.has-my-mark .cn-reveal-btn {
  opacity: 1; transform: none;
}
.cn-reveal-btn:hover { background: var(--green-dk); }

/* Vista Mappa Chiave per Caposquadra (e fine partita per carte non rivelate) */
.cn-card.key-red .cn-front {
  background: linear-gradient(180deg, rgba(168, 32, 42, 0.22) 0%, rgba(168, 32, 42, 0.08) 100%), #f7f0dc;
  border-color: var(--red); border-width: 2.5px;
}
.cn-card.key-red .cn-key-pill { background: var(--red); }

.cn-card.key-blue .cn-front {
  background: linear-gradient(180deg, rgba(36, 82, 122, 0.22) 0%, rgba(36, 82, 122, 0.08) 100%), #f7f0dc;
  border-color: var(--blue); border-width: 2.5px;
}
.cn-card.key-blue .cn-key-pill { background: var(--blue); }

.cn-card.key-neutral .cn-front {
  background: linear-gradient(180deg, rgba(182, 159, 116, 0.26) 0%, rgba(182, 159, 116, 0.1) 100%), #f3ead3;
  border-color: var(--neutral-dk); border-width: 2px;
}
.cn-card.key-neutral .cn-key-pill { background: var(--neutral-dk); }

.cn-card.key-assassin .cn-front {
  background: linear-gradient(180deg, rgba(25, 27, 29, 0.88) 0%, rgba(34, 36, 38, 0.82) 100%);
  border-color: #c9a04b; border-width: 2.5px; color: #f2e9d0;
}
.cn-card.key-assassin .cn-front::before { border-color: rgba(214, 173, 87, 0.35); }
.cn-card.key-assassin .cn-serial { color: rgba(242, 233, 208, 0.55); }
.cn-card.key-assassin .cn-word { background: rgba(15, 16, 18, 0.78); color: #faf4e2; border-color: rgba(214, 173, 87, 0.4); }
.cn-card.key-assassin .cn-key-pill { background: #a8202a; border: 1px solid rgba(250, 244, 226, 0.35); }

/* Retro carta (rivelata) */
.cn-back {
  transform: rotateY(180deg);
  padding: 7px 8px;
  color: #faf4e2;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.08), 0 4px 12px rgba(12, 6, 2, 0.45);
}
.cn-back::before {
  content: ''; position: absolute; inset: 5px;
  border: 1px solid rgba(250, 244, 226, 0.28); border-radius: 3px; pointer-events: none;
}
.cn-back.type-red { background: radial-gradient(circle at 30% 25%, #c42c37, var(--red-dk) 85%); }
.cn-back.type-blue { background: radial-gradient(circle at 30% 25%, #2f699c, var(--blue-dk) 85%); }
.cn-back.type-neutral {
  background: radial-gradient(circle at 30% 25%, #d6c5a3, #a8936d 85%);
  color: #27221a;
}
.cn-back.type-neutral::before { border-color: rgba(31, 42, 36, 0.22); }
.cn-back.type-assassin {
  background: radial-gradient(circle at 30% 25%, #2e3136, #0d0e10 85%);
  border-color: var(--brass);
}
.cn-back.type-assassin::before { border-color: rgba(214, 173, 87, 0.45); }

.cn-back-top {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.88;
  position: relative; z-index: 2;
}
.cn-back-emblem {
  flex: 1; display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 1; opacity: 0.26;
}
.cn-back-emblem .ic { width: clamp(26px, 4vw, 44px); height: clamp(26px, 4vw, 44px); stroke-width: 1.5; }
.cn-back.type-assassin .cn-back-emblem { opacity: 0.85; color: #e05a5a; }

.cn-back-word {
  position: relative; z-index: 2;
  font-family: var(--cond); font-weight: 800; font-size: clamp(0.84rem, 1.35vw, 1.12rem);
  letter-spacing: 0.05em; text-transform: uppercase; text-align: center;
  padding: 2px 6px; border-radius: 3px;
  background: rgba(15, 10, 6, 0.28); color: #faf4e2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cn-back.type-neutral .cn-back-word { background: rgba(31, 42, 36, 0.14); color: #1f2a24; }

/* ---------- BARRA AZIONI INFERIORE ---------- */
.hud-bottom {
  display: flex; justify-content: center; align-items: center; z-index: 12;
  pointer-events: none;
}
.action-bar {
  pointer-events: auto;
  display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center;
  padding: 9px 14px;
  max-width: min(860px, 100%);
}
.action-bar .note {
  font-size: 0.9rem; color: var(--ink-2); font-style: italic; font-family: var(--serif);
  padding: 2px 6px; display: inline-flex; align-items: center; gap: 7px;
}

.clue-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.clue-input {
  width: 210px; padding: 8px 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.num-strip { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.num-btn {
  width: 31px; height: 34px; border-radius: var(--r-btn); border: 1.5px solid var(--rule-2);
  background: var(--card-hi); color: var(--ink); font-family: var(--serif); font-weight: 700; font-size: 0.96rem;
  cursor: pointer; transition: background-color 0.12s, border-color 0.12s, transform 0.08s;
  display: inline-flex; align-items: center; justify-content: center;
}
.num-btn:hover { background: var(--card-2); border-color: var(--ink); }
.num-btn.sel { background: var(--solid); color: var(--on-solid); border-color: var(--solid-bd); }
.num-btn.sel.red { background: var(--red); color: var(--on-accent); border-color: var(--red-dk); }
.num-btn.sel.blue { background: var(--blue); color: var(--on-accent); border-color: var(--blue-dk); }

.guess-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; }
.guess-count { font-size: 0.9rem; font-weight: 600; color: var(--ink-2); }

/* ---------- PANNELLO LATERALE (INDIZI / REGISTRO) ---------- */
.side-panel {
  position: fixed;
  top: max(64px, calc(env(safe-area-inset-top) + 52px));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: 320px; z-index: 22;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(calc(100% + 24px));
  transition: transform 0.26s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.side-panel.open { transform: none; }

.tabs { display: flex; border-bottom: 1px solid var(--rule); padding: 0 6px; }
.tabs button {
  flex: 1; padding: 11px 4px 9px; background: none; border: 0; cursor: pointer;
  color: var(--ink-2); font-weight: 600; font-size: 0.88rem;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--red-ink); }
.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; }

.hist-card {
  background: var(--card-2); border-radius: var(--r-btn); padding: 8px 10px; margin-bottom: 8px;
  border-left: 4px solid var(--tc);
}
.hist-card.red { --tc: var(--red); }
.hist-card.blue { --tc: var(--blue); }
.hist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hist-word { font-family: var(--cond); font-weight: 800; font-size: 1.15rem; letter-spacing: 0.04em; }
.hist-num {
  font-family: var(--serif); font-weight: 800; font-size: 0.95rem;
  padding: 0 7px; border-radius: 3px; background: var(--tc); color: var(--on-accent);
}
.hist-by { font-size: 0.76rem; color: var(--ink-2); margin-top: 1px; }
.hist-guesses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.g-chip {
  font-size: 0.74rem; font-weight: 700; padding: 2px 7px; border-radius: 3px;
  letter-spacing: 0.02em;
}
.g-chip.red { background: var(--red); color: var(--on-accent); }
.g-chip.blue { background: var(--blue); color: var(--on-accent); }
.g-chip.neutral { background: var(--neutral-card); color: #242018; }
.g-chip.assassin { background: var(--assassin); color: #faf4e2; }

.log-item { font-size: 0.83rem; padding: 6px 0; border-bottom: 1px solid var(--rule); line-height: 1.4; }
.log-item time { color: var(--ink-3); font-size: 0.78rem; margin-right: 6px; font-variant-numeric: tabular-nums; }
.empty-note { color: var(--ink-2); font-size: 0.88rem; text-align: center; padding: 18px 8px; font-style: italic; font-family: var(--serif); }

/* ---------- CHAT SUL TAVOLO (stile Monopoly) ---------- */
.chat-box {
  position: fixed; left: 12px; bottom: 12px; width: 278px; height: 245px; z-index: 16;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-card); border: 1px solid transparent;
  transition: height 0.25s ease, background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.chat-box.collapsed { height: 38px; width: 118px; }
.chat-head {
  display: flex; align-items: center; gap: 7px; padding: 9px 12px; background: none; border: 0; cursor: pointer;
  font-weight: 600; font-size: 0.88rem; text-align: left; flex: none; color: var(--cream);
  text-shadow: 0 1px 3px rgba(0,0,0,0.85);
}
.chat-box.collapsed .chat-head { background: rgba(24, 16, 10, 0.62); }
.chat-head .chev { margin-left: auto; transition: transform 0.25s; display: inline-flex; }
.chat-box.collapsed .chev { transform: rotate(180deg); }
.chat-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 10px 10px; }
.chat-box.collapsed .chat-body { visibility: hidden; }
.chat-box .chat-list {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 35%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 35%);
}
.chat-msg { font-size: 0.84rem; background: rgba(24, 16, 10, 0.64); color: var(--cream); border-radius: var(--r-btn); padding: 5px 8px; user-select: text; word-wrap: break-word; }
.chat-msg b { font-weight: 700; }
.chat-msg b::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pc, var(--brass)); margin-right: 5px; vertical-align: 1px; }
.chat-msg .role-mini { font-size: 0.72rem; opacity: 0.78; font-weight: 500; margin-left: 3px; }
.chat-spy-warn { font-size: 0.72rem; color: var(--brass-hi); padding: 2px 4px 5px; font-style: italic; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; padding: 6px 9px; background: rgba(24, 16, 10, 0.55); border-color: rgba(242, 233, 208, 0.25); color: var(--cream); font-size: 0.85rem; }
.chat-form input::placeholder { color: rgba(242, 233, 208, 0.6); }
.chat-form .btn { --fg: var(--cream); --bd: rgba(242, 233, 208, 0.4); padding: 5px 9px; }

.chat-box:hover:not(.collapsed), .chat-box:focus-within:not(.collapsed) {
  background: var(--paper), var(--card); border-color: var(--edge); box-shadow: var(--lift);
}
.chat-box:hover:not(.collapsed) .chat-head, .chat-box:focus-within:not(.collapsed) .chat-head { color: var(--ink); text-shadow: none; }
.chat-box:hover:not(.collapsed) .chat-list, .chat-box:focus-within:not(.collapsed) .chat-list { -webkit-mask-image: none; mask-image: none; }
.chat-box:hover:not(.collapsed) .chat-msg, .chat-box:focus-within:not(.collapsed) .chat-msg { background: var(--card-2); color: var(--ink); }
.chat-box:hover:not(.collapsed) .chat-spy-warn, .chat-box:focus-within:not(.collapsed) .chat-spy-warn { color: var(--red-ink); }
.chat-box:hover:not(.collapsed) .chat-form input, .chat-box:focus-within:not(.collapsed) .chat-form input { background: var(--card-hi); border-color: var(--rule-2); color: var(--ink); }
.chat-box:hover:not(.collapsed) .chat-form .btn, .chat-box:focus-within:not(.collapsed) .chat-form .btn { --fg: var(--ink); --bd: var(--ink); }

.badge {
  min-width: 17px; height: 17px; border-radius: 9px; background: var(--red); color: var(--on-accent);
  font-size: 0.74rem; font-style: normal; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}

.spectators {
  position: fixed; left: 12px; top: 82px; z-index: 10;
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-btn);
  font-size: 0.78rem; color: var(--cream); background: rgba(24, 16, 10, 0.62);
}

/* ---------- MODALI, BANNER, TOAST ---------- */
#modals { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.modal-wrap {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  pointer-events: auto; background: rgba(20, 11, 6, 0.5); animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  padding: 22px 26px; max-width: min(620px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow-y: auto; animation: dealIn 0.35s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
.modal h2 { margin: 0 0 12px; font-size: 1.55rem; line-height: 1.15; display: flex; align-items: center; gap: 10px; }
.modal h2 .ic { width: 0.92em; height: 0.92em; color: var(--ink-2); }
.modal p { line-height: 1.5; margin: 8px 0; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.modal .center { text-align: center; }

.winner-modal { text-align: center; width: min(500px, 100%); border-top: 6px solid var(--wc, var(--brass)); }
.winner-modal.red { --wc: var(--red); }
.winner-modal.blue { --wc: var(--blue); }
.winner-modal h2 { justify-content: center; color: var(--wc); }
.winner-trophy { color: var(--brass); margin-bottom: 6px; }
.winner-trophy .ic { width: 48px; height: 48px; stroke-width: 1.5; }
.winner-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 16px 0 8px;
  background: var(--rule); border: 1px solid var(--rule); border-radius: var(--r-btn); overflow: hidden;
}
.winner-stats div { background: var(--card-hi); padding: 8px; }
.winner-stats span { display: block; font-size: 0.78rem; color: var(--ink-2); }
.winner-stats b { font-family: var(--serif); font-size: 1.25rem; }

.help { font-size: 0.92rem; line-height: 1.55; }
.help h3 { margin: 14px 0 4px; font-size: 1.08rem; }
.help h3:first-child { margin-top: 0; }
.help ul { margin: 4px 0; padding-left: 20px; }

#banner-root { position: fixed; inset: 0; pointer-events: none; z-index: 25; display: flex; align-items: center; justify-content: center; }
.banner {
  font-family: var(--serif); font-weight: 700; font-size: clamp(1.5rem, 4.5vw, 2.5rem); line-height: 1.1; color: var(--ink);
  padding: 15px 28px 15px 22px; border-radius: 4px; background: var(--paper), var(--card-hi);
  border-left: 10px solid var(--bc, var(--brass));
  box-shadow: inset 0 0 0 1px var(--edge), 0 3px 6px rgba(0,0,0,0.3), 0 30px 60px -10px rgba(0,0,0,0.55);
  animation: bannerIn 1.85s cubic-bezier(0.2, 0.9, 0.25, 1) forwards;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
}
.banner small { display: block; font-family: var(--sans); font-size: 0.92rem; color: var(--ink-2); font-weight: 500; margin-top: 4px; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateY(26px) rotate(-1.2deg); }
  15% { opacity: 1; transform: translateY(-2px); }
  22%, 82% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-12px); }
}

#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 9px 16px; border-radius: var(--r-btn); background: var(--solid); color: var(--on-solid);
  box-shadow: 0 10px 30px -8px rgba(0,0,0,0.6); font-size: 0.9rem; font-weight: 500;
  animation: toastIn 3.2s forwards; max-width: 90vw; text-align: center;
}
.toast.error { background: var(--red); color: #fbf2e4; }
.toast.ok { background: var(--green); color: #f0f5ee; }
@keyframes toastIn { 0% { opacity: 0; transform: translateY(-10px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }

#conn-banner {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 45;
  padding: 10px 18px; border-radius: var(--r-btn); background: var(--red); color: #fbf2e4;
  font-weight: 600; display: flex; gap: 10px; align-items: center; box-shadow: var(--lift);
}
.spinner { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- AUDIO & ASPETTO POPOVER ---------- */
.audio-fab { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 12; }
.gfx-fab { position: fixed; right: max(62px, calc(env(safe-area-inset-right) + 48px)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 12; }
body.in-game .audio-fab, body.in-game .gfx-fab { display: none; }

.gfx-pop { position: fixed; z-index: 36; width: 270px; padding: 12px 14px 12px; display: flex; flex-direction: column; gap: 9px; animation: dealIn 0.22s both; }
.gp-title { font-family: var(--serif); font-weight: 700; font-size: 1.08rem; }
.gp-row { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 10px; font-size: 0.88rem; font-weight: 600; color: var(--ink-2); }
.gp-row select { min-width: 0; background: var(--card-hi); border: 1.5px solid var(--rule-2); border-radius: var(--r-btn); padding: 6px 8px; color: var(--ink); font-weight: 500; }

.audio-pop { position: fixed; z-index: 36; width: 245px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; animation: dealIn 0.22s both; }
.ap-row { display: flex; align-items: center; gap: 10px; }
.ap-toggle {
  display: inline-flex; align-items: center; gap: 7px; width: 92px; flex: none; padding: 6px 4px;
  border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 0.88rem; text-align: left; border-radius: var(--r-btn);
}
.ap-toggle[aria-pressed=false] { color: var(--ink-3); text-decoration: line-through; }
.ap-row input[type=range] { flex: 1; min-width: 0; }
.ap-row input[type=range]:disabled { opacity: 0.35; }

/* ---------- LINGUA ---------- */
.lang-switch { display: flex; justify-content: center; gap: 4px; margin-top: 12px; }
.lang-switch button {
  border: 0; background: none; cursor: pointer; padding: 4px 10px; border-radius: var(--r-btn);
  font-size: 0.82rem; font-weight: 500; color: var(--ink-2); transition: background-color 0.15s, color 0.15s;
}
.lang-switch button:hover { background: var(--card-2); color: var(--ink); }
.lang-switch button[aria-pressed=true] { background: var(--card-2); color: var(--ink); font-weight: 700; cursor: default; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1020px) {
  .lobby-body { grid-template-columns: 1fr 1fr; }
  .lobby-teams-col { grid-column: 1 / -1; }
  .game-top { grid-template-columns: 1fr 1fr; }
  .turn-center { grid-column: 1 / -1; order: 3; }
  .top-right-group { justify-content: flex-end; }
  .chat-box { width: 240px; height: 210px; }
}

@media (max-width: 780px) {
  #home { justify-content: center; padding-left: 16px; }
  .lobby-body { grid-template-columns: 1fr; gap: 18px; }
  .team-panels { grid-template-columns: 1fr; }
  .lobby-card { padding: 16px; }
  .code { font-size: 2rem; }
  .th-roster { display: none; }
  .th-score { width: 34px; min-width: 34px; height: 34px; font-size: 1.4rem; }
  .team-hud { padding: 5px 8px; }
  .hud-tools .icon-btn { width: 34px; height: 34px; }
  .board { gap: 5px; }
  .cn-front { padding: 4px; }
  .cn-serial { display: none; }
  .cn-word { font-size: clamp(0.76rem, 2.8vw, 1.05rem); padding: 3px 4px; }
  .chat-box { left: 8px; bottom: 8px; }
  .chat-box:not(.collapsed) {
    width: calc(100vw - 16px); height: 38vh;
    background: var(--paper), var(--card); border-color: var(--edge); box-shadow: var(--lift);
  }
  .chat-box:not(.collapsed) .chat-head { color: var(--ink); text-shadow: none; }
  .chat-box:not(.collapsed) .chat-list { -webkit-mask-image: none; mask-image: none; }
  .chat-box:not(.collapsed) .chat-msg { background: var(--card-2); color: var(--ink); }
  .chat-box:not(.collapsed) .chat-form input { background: var(--card-hi); border-color: var(--rule-2); color: var(--ink); }
  .chat-box:not(.collapsed) .chat-form .btn { --fg: var(--ink); --bd: var(--ink); }
  .side-panel { width: min(340px, calc(100vw - 16px)); }
  .clue-input { width: 155px; }
  .lobby-foot { flex-wrap: wrap; }
  .lobby-foot .hint { order: -1; flex-basis: 100%; }
  .lobby-foot #btn-start { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .deal-in, .modal, .btn.pulse, .banner, .active-clue-bar, .audio-pop, .gfx-pop { animation: none !important; }
  .cn-inner, .cn-card, .side-panel, .chat-box { transition: none !important; }
}
