:root {
  --bg: #050506;
  --panel: rgba(12, 10, 10, 0.82);
  --line: rgba(255, 255, 255, 0.1);
  --text: #d8d2c8;
  --muted: #8a837a;
  --blood: #a3191b;
  --blood-hi: #d22a2c;
  --torch: #ffd88a;
  --font: 'Georgia', 'Times New Roman', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.75) 100%); }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(0,0,0,0.25), rgba(0,0,0,0.85)); overflow-y: auto; }
.title { font-size: clamp(42px, 9vw, 96px); letter-spacing: 0.25em; margin: 0 0 4px; color: #e9e1d4; text-shadow: 0 0 24px rgba(163,25,27,0.8), 0 0 2px #000; animation: flicker 6s infinite; }
h2 { font-weight: normal; letter-spacing: 0.1em; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 24px; font-style: italic; text-align: center; }
.panel { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line); padding: 20px; border-radius: 4px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.field { display: block; margin-bottom: 16px; color: var(--muted); font-size: 14px; letter-spacing: 0.05em; }
input { width: 100%; margin-top: 6px; padding: 10px 12px; background: #0d0b0b; color: var(--text); border: 1px solid var(--line); border-radius: 3px; font: inherit; font-size: 16px; }
input:focus { outline: 1px solid var(--blood); }
button { padding: 11px 16px; background: #1a1515; color: var(--text); border: 1px solid var(--line); border-radius: 3px; font: inherit; font-size: 15px; cursor: pointer; transition: background .15s, border-color .15s; }
button:hover { background: #241c1c; border-color: rgba(255,255,255,0.25); }
button.primary { background: var(--blood); border-color: var(--blood-hi); color: #fff; }
button.primary:hover { background: var(--blood-hi); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.buttons button { flex: 1; }
.join-code { display: flex; gap: 10px; margin-top: 12px; }
.join-code input { margin: 0; text-transform: uppercase; letter-spacing: 0.3em; }
.error { color: var(--blood-hi); min-height: 1.2em; margin: 10px 0 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

.chars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 8px; }
.char { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; background: #0d0b0b; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; color: var(--text); font-size: 13px; }
.char.selected { border-color: var(--blood-hi); box-shadow: 0 0 0 1px var(--blood-hi) inset; }
.char .figure { width: 22px; height: 36px; border-radius: 11px 11px 6px 6px; position: relative; box-shadow: 0 0 10px rgba(0,0,0,0.8) inset; }
.char .figure::before { content: ''; position: absolute; top: -14px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: inherit; }
.chars.small .char { padding: 6px 4px; font-size: 12px; }
.chars.small .figure { transform: scale(0.75); }

.players { list-style: none; padding: 0; margin: 0 0 16px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.players .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.players .tag { margin-left: auto; font-size: 12px; color: var(--muted); }
.players .tag.seeker { color: var(--blood-hi); }
.code { color: var(--torch); letter-spacing: 0.3em; }
.controls-help { margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; max-width: 620px; line-height: 1.6; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#topbar { position: absolute; top: 14px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 14px; padding: 0 16px; flex-wrap: wrap; }
#timer { font-size: 32px; letter-spacing: 0.1em; text-shadow: 0 0 10px #000; min-width: 110px; text-align: center; }
#timer.urgent { color: var(--blood-hi); }
.badge { padding: 5px 12px; background: rgba(0,0,0,0.55); border: 1px solid var(--line); border-radius: 3px; font-size: 14px; }
#role.seeker { color: var(--blood-hi); border-color: var(--blood); }
#role.fugitive { color: var(--torch); }
#crosshair { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: rgba(255,255,255,0.5); }
#prompt { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); padding: 8px 14px; background: rgba(120,10,12,0.75); border: 1px solid var(--blood-hi); border-radius: 3px; font-size: 16px; }
#feed { position: absolute; left: 16px; bottom: 80px; display: flex; flex-direction: column; gap: 6px; max-width: min(420px, calc(100% - 32px)); }
#feed div { padding: 6px 10px; background: rgba(0,0,0,0.6); border-left: 2px solid var(--blood); font-size: 14px; animation: fadeout 7s forwards; }
#battery { position: absolute; left: 16px; bottom: 24px; display: flex; align-items: center; gap: 10px; font-size: 12px; letter-spacing: 0.15em; color: var(--muted); }
#battery .bar { width: 160px; height: 8px; background: rgba(255,255,255,0.08); border: 1px solid var(--line); }
#batteryFill { height: 100%; width: 100%; background: var(--torch); transition: width .2s linear; }
#batteryFill.low { background: var(--blood-hi); }
#status { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 22px; text-align: center; text-shadow: 0 0 12px #000; padding: 0 16px; }

#blind { position: fixed; inset: 0; background: #000; display: flex; align-items: center; justify-content: center; text-align: center; }
#blind p#blindCount { font-size: 72px; margin: 10px 0; color: var(--blood-hi); }
#clickToPlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,0.45); font-size: 26px; letter-spacing: 0.1em; cursor: pointer; }

@keyframes flicker { 0%, 92%, 100% { opacity: 1; } 93% { opacity: 0.4; } 94% { opacity: 1; } 96% { opacity: 0.6; } }
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

.maps { display: grid; gap: 8px; margin-top: 8px; }
.map-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 10px 12px; background: #0d0b0b; }
.map-card b { font-weight: normal; letter-spacing: 0.08em; color: var(--text); }
.map-card span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.map-card.selected { border-color: var(--blood-hi); box-shadow: 0 0 0 1px var(--blood-hi) inset; }
.map-card:disabled { opacity: 0.35; }
.map-card.selected:disabled { opacity: 1; }
.hint-inline { font-size: 12px; margin-left: 6px; }

.char .thumb { width: 72px; height: 94px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.7)); }
.chars.small .char .thumb { width: 52px; height: 68px; }

#boost { color: #8dffa8; letter-spacing: 0.1em; text-shadow: 0 0 8px rgba(120,255,150,0.5); }

/* ---------- Hidebound: splash, start, passi del menu ---------- */
.splash { background: #000; cursor: pointer; }
.splash-logo { width: min(720px, 88vw); opacity: 0.12; filter: drop-shadow(0 0 30px rgba(0,0,0,0.9)); }
.splash.leaving { animation: fadeOutScreen 0.6s forwards; }
@keyframes splashIn {
  0% { opacity: 0; transform: scale(0.96); filter: brightness(0.2) drop-shadow(0 0 30px #000); }
  30% { opacity: 1; }
  34% { opacity: 0.25; } 37% { opacity: 1; } 41% { opacity: 0.5; } 44% { opacity: 1; }
  100% { opacity: 1; transform: scale(1); filter: brightness(1) drop-shadow(0 0 30px #000); }
}
@keyframes fadeOutScreen { to { opacity: 0; } }
.pulse { animation: pulse 2s ease-in-out infinite; opacity: 0; animation-delay: 1.6s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 0.9; } }
.logo { width: min(640px, 86vw); margin-bottom: 6px; filter: drop-shadow(0 6px 24px rgba(0,0,0,0.9)); animation: flicker 7s infinite; }
.logo.small { width: min(340px, 70vw); margin-bottom: 14px; }
button.big { font-size: 22px; letter-spacing: 0.35em; padding: 14px 64px 14px 70px; }
button.link { background: none; border: none; color: var(--muted); padding: 10px 0 0; font-size: 14px; }
button.link:hover { color: var(--text); background: none; }
.step { margin: 0 0 14px; font-weight: normal; letter-spacing: 0.12em; color: var(--torch); }
.rooms-field { margin-top: 16px; }
.room-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 3px; }
.room-list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--text); font-size: 14px; }
.room-list li:last-child { border-bottom: none; }
.room-list li .code { font-size: 15px; }
.room-list li .meta { color: var(--muted); font-size: 12px; }
.room-list li button { margin-left: auto; padding: 6px 14px; font-size: 13px; }
.room-list li.empty { color: var(--muted); font-style: italic; justify-content: center; }

.splash.ready .splash-logo { animation: splashIn 3.2s ease-out forwards; }
.splash:not(.ready) .pulse { animation-delay: 0s; }
.logo.tiny { width: min(220px, 55vw); margin-bottom: 6px; }

/* ================================================================
   STILE "TOPPE DI JUTA" (come le lettere del logo)
   ================================================================ */
:root {
  --stitch: rgba(244, 228, 196, 0.85);
  --outline: #1c120a;
  --western: 'Rye', 'Georgia', serif;
}
h2, .step, .title, button, .code, #timer, .badge { font-family: var(--western); font-weight: normal; }

/* riquadri: juta scura, bordo sfrangiato, cucitura a punti */
.panel {
  position: relative;
  background: var(--burlap-dark), #241910;
  background-size: 200px;
  border: none;
  border-radius: 0;
  clip-path: var(--ragged);
  box-shadow: none;
  padding: 26px 26px 22px;
  filter: drop-shadow(0 14px 30px rgba(0,0,0,0.85));
}
.panel::before {
  content: ''; position: absolute; inset: 9px; pointer-events: none;
  border: 2px dashed rgba(220, 196, 150, 0.45);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.55);
}
.panel::after { /* ombra interna lungo i bordi, come stoffa imbottita */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,0.6), inset 0 0 22px rgba(0,0,0,0.7);
}
.panel > * { position: relative; z-index: 1; }
.step { color: #e2c48e; text-shadow: 0 2px 0 #000; font-size: 18px; letter-spacing: 0.06em; }

/* pulsanti: toppe di juta chiara cucite, tonalità diverse */
button {
  position: relative;
  --tint: #b38a5a;
  background: var(--burlap-light), var(--tint);
  background-blend-mode: multiply;
  background-size: 160px;
  background-color: var(--tint);
  color: #2a1a0c;
  text-shadow: 0 1px 0 rgba(255, 235, 200, 0.45);
  border: 3px solid var(--outline);
  border-radius: 0;
  clip-path: var(--ragged);
  transform: rotate(var(--tilt, 0deg));
  font-size: 16px; letter-spacing: 0.06em;
  padding: 12px 18px;
  box-shadow: inset 0 0 0 2px rgba(255, 230, 190, 0.18), inset 0 -6px 14px rgba(40, 20, 5, 0.45), inset 0 6px 10px rgba(255, 235, 200, 0.18);
  transition: transform .12s, filter .12s;
}
button::after { /* cucitura */
  content: ''; position: absolute; inset: 5px; pointer-events: none;
  border: 2px dashed var(--stitch);
  opacity: 0.85;
}
button:hover { background-color: var(--tint); filter: brightness(1.12); transform: rotate(var(--tilt, 0deg)) translateY(-1px); border-color: var(--outline); }
button:active { transform: rotate(var(--tilt, 0deg)) translateY(1px); filter: brightness(0.95); }
button:disabled { filter: grayscale(0.6) brightness(0.55); opacity: 1; }
button.primary {
  --tint: #8e2a1c;
  color: #f4e2c4;
  text-shadow: 0 2px 0 #2a0904;
  background-color: var(--tint);
}
button.primary:hover { background-color: var(--tint); }
button.big { font-size: 28px; letter-spacing: 0.25em; padding: 16px 60px 16px 70px; }
button.link { clip-path: none; transform: none; box-shadow: none; border: none; background: none; color: #c9ad80; font-family: var(--western); }
button.link::after { display: none; }

/* campi di testo: juta media, scritta come cucita */
input {
  background: var(--burlap-mid), #6b5034;
  background-size: 160px;
  background-blend-mode: multiply;
  background-color: #574029;
  color: #f4e4c6;
  border: 3px solid var(--outline);
  border-radius: 0;
  clip-path: var(--ragged);
  font-family: var(--western);
  text-shadow: 0 1px 0 #000;
  box-shadow: inset 0 3px 10px rgba(0,0,0,0.6);
}
input::placeholder { color: rgba(240, 220, 185, 0.5); }
input:focus { outline: none; box-shadow: inset 0 3px 10px rgba(0,0,0,0.6), inset 0 0 0 2px var(--stitch); }

/* schede personaggio e mappe: toppe più scure, cucitura quando selezionate */
.char, .map-card {
  position: relative;
  background: var(--burlap-mid), #4c3622;
  background-blend-mode: multiply;
  background-size: 160px;
  background-color: #3f2d1c;
  border: 3px solid var(--outline);
  border-radius: 0;
  clip-path: var(--ragged);
  color: #ead6b2;
  font-family: var(--western);
  transform: none;
  text-shadow: 0 1px 0 #000;
  box-shadow: inset 0 0 18px rgba(0,0,0,0.6);
}
.char::after, .map-card::after { border-color: rgba(230, 210, 170, 0.25); }
.char.selected, .map-card.selected { background-color: #7a4a26; box-shadow: inset 0 0 18px rgba(0,0,0,0.4); }
.char.selected::after, .map-card.selected::after { border-color: var(--stitch); opacity: 1; }
.map-card b { color: #f0dcb6; font-family: var(--western); }
.map-card span { color: #cdb48c; font-family: Georgia, serif; }

/* elenco stanze e giocatori */
.room-list {
  background: rgba(0,0,0,0.35);
  border: 2px dashed rgba(220, 196, 150, 0.3);
  border-radius: 0;
}
.room-list li { border-bottom: 1px dashed rgba(220, 196, 150, 0.2); }
.room-list li button { font-size: 13px; padding: 7px 14px; }
.players li { border-bottom: 1px dashed rgba(220, 196, 150, 0.25); }
.code { color: #f0c878; text-shadow: 0 2px 0 #000; }
.field { color: #c9ad80; }
.hint, .subtitle { color: #b39a74; }
h2 { color: #ead6b2; text-shadow: 0 2px 0 #000; }

/* HUD: badge come etichette cucite */
.badge {
  position: relative;
  background: var(--burlap-dark), #241910;
  background-size: 160px;
  border: 2px solid var(--outline);
  border-radius: 0;
  clip-path: var(--ragged);
  color: #ead6b2;
  padding: 6px 14px;
}
.badge::after { content: ''; position: absolute; inset: 3px; border: 1px dashed rgba(220, 196, 150, 0.4); pointer-events: none; }
#timer { text-shadow: 0 2px 0 #000, 0 0 14px rgba(0,0,0,0.9); }
#prompt { font-family: var(--western); border-radius: 0; }

/* correzioni: niente bordi rossi del vecchio stile, hover coerente */
button, button:hover, button.primary, button.primary:hover,
.char, .char.selected, .map-card, .map-card.selected { border-color: var(--outline); outline: none; }
button:focus-visible { outline: none; filter: brightness(1.15); }
.char:hover, .map-card:hover { background-color: #5a3f26; filter: brightness(1.1); }
.char.selected:hover, .map-card.selected:hover { background-color: #7a4a26; }
.map-card:disabled { filter: brightness(0.5); }
.map-card:disabled:hover { background-color: #3f2d1c; filter: brightness(0.5); }

/* ---------- Lobby a due colonne ---------- */
.lobby-panel { width: min(940px, 100%); }
.lobby-cols { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 26px; }
.lobby-left { border-right: 2px dashed rgba(220, 196, 150, 0.25); padding-right: 22px; min-width: 0; }
.lobby-left .players { margin: 0; max-height: 440px; overflow-y: auto; }
.lobby-left .players li { padding: 10px 4px; }
.lobby-right { min-width: 0; }
.lobby-right .field:last-child { margin-bottom: 0; }
.lobby-actions { justify-content: center; margin-top: 22px; }
.lobby-actions button { flex: 0 1 220px; }
.lobby-hint { text-align: center; }
@media (max-width: 760px) {
  .lobby-cols { grid-template-columns: 1fr; gap: 16px; }
  .lobby-left { border-right: none; padding-right: 0; border-bottom: 2px dashed rgba(220, 196, 150, 0.25); padding-bottom: 14px; }
}

/* contenuto più alto dello schermo: scorre invece di essere tagliato in alto */
.screen { justify-content: safe center; }

/* ================================================================
   LOBBY COMPATTA: tutto visibile senza scorrere, adattiva
   ================================================================ */
#lobby {
  height: 100vh; height: 100dvh;
  justify-content: flex-start; overflow: hidden;
  padding: clamp(8px, 1.6vh, 20px) clamp(10px, 2vw, 24px);
  gap: clamp(6px, 1.2vh, 14px);
}
.lobby-head { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 2vw, 22px); flex: none; }
.lobby-head .logo.tiny { width: auto; height: clamp(34px, 8vh, 84px); margin: 0; }
.lobby-title h2 { font-size: clamp(18px, 3.2vh, 30px); margin: 0; line-height: 1.1; }
.lobby-title .subtitle { margin: 2px 0 0; font-size: clamp(11px, 1.6vh, 15px); text-align: left; }
.lobby-panel {
  flex: 1 1 auto; min-height: 0;
  width: min(1000px, 100%);
  display: flex; flex-direction: column;
  padding: clamp(14px, 2.2vh, 26px) clamp(14px, 2vw, 26px) clamp(10px, 1.6vh, 20px);
}
.lobby-cols { flex: 1 1 auto; min-height: 0; gap: clamp(12px, 2vw, 26px); }
.lobby-left, .lobby-right { display: flex; flex-direction: column; min-height: 0; }
.lobby-left .step { margin-bottom: clamp(4px, 1vh, 12px); font-size: clamp(14px, 2.2vh, 18px); }
/* 10 posti fissi che si dividono l'altezza disponibile */
.lobby-left .players {
  flex: 1 1 auto; min-height: 0; max-height: none; overflow: hidden;
  display: grid; grid-template-rows: repeat(10, minmax(0, 1fr));
}
.lobby-left .players li { padding: 0 4px; min-height: 0; font-size: clamp(12px, 1.9vh, 16px); gap: 8px; }
.lobby-left .players li .tag { font-size: clamp(10px, 1.4vh, 12px); }
.lobby-left .players li.free { color: rgba(200, 175, 135, 0.35); font-style: italic; }
.lobby-left .players li.free .dot { background: none; border: 1px dashed rgba(200, 175, 135, 0.35); }
.players .dot { width: clamp(8px, 1.3vh, 12px); height: clamp(8px, 1.3vh, 12px); }
/* colonna destra: mappe in alto, personaggi che riempiono il resto */
.lobby-right .field { margin-bottom: clamp(6px, 1.2vh, 14px); font-size: clamp(12px, 1.7vh, 14px); }
.lobby-right .field:last-child { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0; }
.lobby-right .maps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(6px, 1vh, 8px); margin-top: clamp(4px, 0.8vh, 8px); }
.lobby-right .map-card { padding: clamp(6px, 1.1vh, 10px) 12px; gap: 2px; }
.lobby-right .map-card b { font-size: clamp(13px, 1.9vh, 16px); }
.lobby-right .map-card span { font-size: clamp(10px, 1.35vh, 12px); line-height: 1.3; }
#lobbyChars {
  flex: 1 1 auto; min-height: 0;
  grid-template-rows: repeat(2, minmax(0, 1fr)); gap: clamp(5px, 0.9vh, 8px); margin-top: clamp(4px, 0.8vh, 8px);
}
#lobbyChars .char { min-height: 0; padding: clamp(3px, 0.6vh, 6px) 4px; gap: 2px; font-size: clamp(10px, 1.5vh, 13px); justify-content: center; }
#lobbyChars .char .thumb { width: auto; height: 100%; max-height: clamp(30px, 11vh, 110px); min-height: 0; flex: 1 1 auto; object-fit: contain; }
.lobby-actions { margin-top: clamp(8px, 1.6vh, 20px); flex: none; }
.lobby-actions button { padding: clamp(8px, 1.3vh, 12px) 18px; font-size: clamp(14px, 2vh, 16px); }
.lobby-hint { margin: clamp(4px, 0.8vh, 10px) 0 0; font-size: clamp(11px, 1.5vh, 13px); flex: none; }
.lobby-help { margin: 0; flex: none; font-size: clamp(10px, 1.4vh, 13px); line-height: 1.4; }

/* schermi bassi: via le descrizioni delle mappe e i comandi */
@media (max-height: 760px) { .lobby-right .map-card span { display: none; } }
@media (max-height: 620px) { .lobby-help { display: none; } .lobby-panel::before { inset: 6px; } }

/* telefono / finestre strette: colonne impilate, giocatori su due colonne */
@media (max-width: 760px) {
  .lobby-cols { display: flex; flex-direction: column; gap: 10px; }
  .lobby-left { flex: 0 0 auto; border-right: none; padding-right: 0; border-bottom: 2px dashed rgba(220, 196, 150, 0.25); padding-bottom: 8px; }
  .lobby-left .players { grid-template-rows: repeat(5, clamp(18px, 3.2vh, 28px)); grid-auto-flow: column; grid-template-columns: 1fr 1fr; column-gap: 14px; }
  .lobby-left .players li .tag { display: none; }
  .lobby-right { flex: 1 1 auto; }
  .lobby-right .map-card span { display: none; }
  .lobby-help { display: none; }
  .lobby-head .logo.tiny { height: clamp(30px, 6vh, 56px); }
}

/* rifiniture lobby: miniature che crescono con la scheda, griglia sempre dentro lo schermo */
#lobby { justify-content: safe center; }
.lobby-panel { max-height: 880px; }
#lobbyChars { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#lobbyChars .char { min-width: 0; overflow: hidden; }
#lobbyChars .char .thumb { max-height: none; max-width: 100%; height: 0; flex: 1 1 0; width: 100%; }
.lobby-right .maps > * { min-width: 0; }
@media (max-width: 760px) {
  .lobby-right .map-card b { font-size: 13px; }
  #lobbyChars .char { font-size: 11px; }
}

/* lobby: logo centrato, piede con stanza a sinistra e pulsanti a destra */
.lobby-head { justify-content: center; }
.lobby-foot {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: clamp(8px, 1.6vh, 18px); padding-top: clamp(8px, 1.4vh, 14px);
  border-top: 2px dashed rgba(220, 196, 150, 0.25);
}
.lobby-room { min-width: 0; }
.lobby-room h2 { margin: 0; font-size: clamp(16px, 2.6vh, 24px); line-height: 1.15; }
.lobby-room .room-kind { font-family: Georgia, serif; font-style: italic; font-size: clamp(11px, 1.6vh, 14px); color: #b39a74; letter-spacing: 0; text-shadow: none; }
.lobby-room .lobby-hint { text-align: left; margin: 3px 0 0; }
.lobby-foot .lobby-actions { margin: 0; flex: none; justify-content: flex-end; flex-wrap: nowrap; }
.lobby-foot .lobby-actions button { flex: none; min-width: clamp(110px, 14vw, 190px); }
@media (max-width: 760px) {
  .lobby-foot { flex-direction: column; align-items: stretch; gap: 8px; }
  .lobby-foot .lobby-actions { justify-content: stretch; }
  .lobby-foot .lobby-actions button { flex: 1; min-width: 0; }
}

/* indicatore di rumore dei fuggitivi */
#noise { position: absolute; left: 16px; bottom: 48px; font-family: var(--western); font-size: 13px; letter-spacing: 0.12em; padding: 4px 10px; background: rgba(0,0,0,0.55); border: 1px dashed rgba(220,196,150,0.35); color: #9fbf9a; transition: color .2s, border-color .2s; }
#noise[data-level="1"] { color: #e2c48e; }
#noise[data-level="2"] { color: #ff5a3a; border-color: #ff5a3a; animation: noisePulse 0.6s ease-in-out infinite; }
@keyframes noisePulse { 50% { opacity: 0.55; } }

/* indicatore del rumore: arco sottile con alone attorno al mirino, punta minima */
#noiseArrows { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.noise-arrow { position: absolute; left: 0; top: 0; color: #d6ba8c; will-change: transform, opacity; }
.noise-arrow svg { width: 100%; height: 100%; overflow: visible; }
.noise-arrow .halo { fill: none; stroke-width: 9; stroke-linecap: round; opacity: 0.35; filter: blur(4px); }
.noise-arrow .arc { fill: none; stroke-width: 2.2; stroke-linecap: round; }
.noise-arrow .tip { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 3px currentColor); }

/* ================================================================
   COMANDI TOUCH
   ================================================================ */
#touchUI { position: fixed; inset: 0; z-index: 5; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
/* joystick e pulsanti semitrasparenti: si vede il gioco attraverso */
#stickBase {
  position: absolute; width: 120px; height: 120px; transform: translate(-50%, -50%); border-radius: 50%;
  border: 1.5px dashed rgba(240, 225, 195, 0.35); background: radial-gradient(circle, rgba(255,240,210,0.07), rgba(0,0,0,0.12));
  opacity: 0; transition: opacity .12s; pointer-events: none;
}
#stickBase.on { opacity: 1; }
#stickBase.run { border-color: rgba(255, 90, 60, 0.6); }
#stickKnob {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; border-radius: 50%; transform: translate(-50%, -50%);
  background: rgba(230, 205, 160, 0.22); border: 1.5px solid rgba(250, 235, 205, 0.5);
  box-shadow: inset 0 0 0 4px rgba(0,0,0,0.12);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
/* torcia grande in basso a destra; Corri, Giù e Salta ad arco attorno; Cattura sopra */
.tbtns {
  --tr: max(16px, env(safe-area-inset-right)); --tb: max(14px, env(safe-area-inset-bottom));
  --T: 96px;                 /* diametro torcia */
  --A: 60px;                 /* diametro pulsanti dell'arco */
  --R: 108px;                /* distanza dal centro della torcia */
  position: absolute; right: 0; bottom: 0; width: 0; height: 0;
}
.tbtn {
  position: absolute; padding: 0; border-radius: 50%; clip-path: none; transform: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 10px; letter-spacing: 0.04em; touch-action: none;
  background: rgba(30, 20, 12, 0.22) !important; color: rgba(250, 238, 215, 0.85); text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  border: 1.5px solid rgba(240, 225, 195, 0.42); box-shadow: none;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.tbtn::after { border-radius: 50%; inset: 4px; border-width: 1px; border-color: rgba(240, 225, 195, 0.28); }
.tbtn span { font-size: 22px; line-height: 1; font-family: system-ui, sans-serif; }
.tbtn.torch { width: var(--T); height: var(--T); right: var(--tr); bottom: var(--tb); font-size: 12px; }
.tbtn.torch span { font-size: 34px; }
.tbtn.arc { width: var(--A); height: var(--A); }
/* centro torcia = (right: tr + T/2, bottom: tb + T/2); pulsante a angolo θ (180° = sinistra, 90° = sopra) */
.tbtn.a1 { right: calc(var(--tr) + var(--T) / 2 + var(--R) - var(--A) / 2); bottom: calc(var(--tb) + var(--T) / 2 - var(--A) / 2); }               /* 180° */
.tbtn.a2 { right: calc(var(--tr) + var(--T) / 2 + var(--R) * 0.7071 - var(--A) / 2); bottom: calc(var(--tb) + var(--T) / 2 + var(--R) * 0.7071 - var(--A) / 2); } /* 135° */
.tbtn.a3 { right: calc(var(--tr) + var(--T) / 2 - var(--A) / 2); bottom: calc(var(--tb) + var(--T) / 2 + var(--R) - var(--A) / 2); }               /* 90° */
.tbtn.pressed { background: rgba(255, 240, 210, 0.22) !important; transform: scale(0.94); }
.tbtn.active { background: rgba(255, 205, 110, 0.32) !important; border-color: rgba(255, 220, 150, 0.85); color: #fff3d6; box-shadow: 0 0 14px rgba(255, 200, 110, 0.45); }
.tbtn.active::after { border-color: rgba(255, 230, 180, 0.6); }
.tbtn.disabled { opacity: 0.25; pointer-events: none; }
/* Cattura: stesso cerchio dei pulsanti dell'arco, in rosso, subito a sinistra di Corri */
.tbtn.catch {
  width: var(--A); height: var(--A);
  right: calc(var(--tr) + var(--T) / 2 + var(--R) + var(--A) / 2 + 12px); bottom: calc(var(--tb) + var(--T) / 2 - var(--A) / 2);
  background: rgba(140, 18, 10, 0.3) !important; border-color: rgba(255, 110, 90, 0.55); color: rgba(255, 220, 210, 0.9);
}
.tbtn.catch::after { border-color: rgba(255, 140, 120, 0.35); }
.tbtn.catch span { font-size: 22px; }
.tbtn.catch.ready { background: rgba(215, 30, 16, 0.55) !important; border-color: rgba(255, 150, 130, 0.95); color: #fff; animation: catchPulse 0.7s ease-in-out infinite; }
@keyframes catchPulse { 50% { box-shadow: 0 0 20px rgba(255, 40, 20, 0.75); } }
@media (max-height: 400px) { .tbtns { --T: 84px; --A: 54px; --R: 96px; } }
.touch-hint { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); margin: 0; font-size: 11px; color: rgba(220, 200, 165, 0.45); pointer-events: none; white-space: nowrap; }
/* su touch l'HUD in basso a sinistra lascia spazio al joystick */
body.touch #battery { bottom: auto; top: 64px; left: 14px; }
body.touch #noise { bottom: auto; top: 92px; left: 14px; }
body.touch #feed { bottom: auto; top: 128px; left: 14px; max-width: 46vw; }
body.touch .controls-help { display: none; }
body.touch #clickToPlay { display: none !important; }
#rotateHint { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #e2c48e; font-family: var(--western); text-align: center; padding: 20px; }
#rotateHint div { font-size: 64px; animation: spin 2.4s ease-in-out infinite; }
@keyframes spin { 50% { transform: rotate(90deg); } }
.tbtn .ticon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 1px; }

/* personaggio già scelto da un altro giocatore */
.char.taken { filter: grayscale(0.85) brightness(0.45); cursor: not-allowed; }
.char.taken:hover { background-color: #3f2d1c; filter: grayscale(0.85) brightness(0.45); }
.char .cname { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.char.taken .cname { font-family: Georgia, serif; font-style: italic; }

/* logo dello studio: splash iniziale e firma in basso a destra nella schermata START */
.studio { z-index: 2; }
.studio-logo { width: min(340px, 62vw); opacity: 0; animation: studioIn 1.4s ease-out 0.2s forwards; }
.studio-hint { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: rgba(200, 200, 200, 0.35); font-family: system-ui, sans-serif; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; }
.studio.leaving { animation: fadeOutScreen 0.7s forwards; }
@keyframes studioIn { from { opacity: 0; transform: scale(0.97); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }
.splash.ready .pulse { animation-delay: 1.6s; }
.studio-mark {
  position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: clamp(70px, 9vw, 120px); opacity: 0.55; pointer-events: none; transition: opacity .3s;
}
@media (max-height: 420px) { .studio-mark { width: 64px; } }
.studio { background: #000 !important; }
/* schermata START: il logo si adatta all'altezza, START resta sempre visibile */
#startScreen .logo { width: auto; max-width: min(640px, 86vw); max-height: 52vh; object-fit: contain; }
#startScreen .subtitle { margin-bottom: clamp(10px, 3vh, 24px); }
@media (max-height: 460px) {
  #startScreen .logo { max-height: 46vh; }
  #startScreen .subtitle { margin: 2px 0 10px; font-size: 13px; }
  button.big { font-size: 20px; padding: 10px 44px 10px 50px; }
}
.splash { background: #000 !important; }
#studio { z-index: 3; }
#splash { z-index: 2; }
