@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url('/fonts/plus-jakarta-sans-latin-variable.woff2') format('woff2');
}

:root {
  --bg: #08111f;
  --glass: rgba(10, 21, 38, 0.82);
  --glass-strong: rgba(8, 17, 32, 0.95);
  --line: rgba(212, 175, 55, 0.25);
  --line-strong: rgba(212, 175, 55, 0.58);
  --gold: #d4af37;
  --gold-soft: #ead07d;
  --blue: #1a7bb5;
  --orange: #ec671b;
  --text: #f3efe6;
  --muted: #9eb0c7;
  --danger: #e25d6d;
  --ok: #38c77f;
  --radius: 14px;
  --font-display: 'Cinzel', 'Cormorant Garamond', Georgia, serif;
  --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
kbd { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line-strong); background: rgba(212, 175, 55, 0.12); font: 700 11px var(--font); color: var(--gold-soft); }

#css3d, #stage3d, #labels { position: fixed; inset: 0; }
#css3d { z-index: 0; }
#css3d iframe { border: 0; background: #000; }
#stage3d { z-index: 1; }
#stage3d canvas { display: block; width: 100%; height: 100%; outline: none; }
#labels { z-index: 2; pointer-events: none; }

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(125%);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}
.muted { color: var(--muted); }
.x { background: none; border: 0; color: var(--muted); font-size: 16px; width: 30px; height: 30px; border-radius: 8px; }
.x:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* ---------- sigillo istituzionale ---------- */
.seal-logo {
  position: relative; width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: radial-gradient(circle, rgba(26, 123, 181, 0.28), rgba(8, 17, 31, 0.96) 72%);
  border: 2px solid rgba(212, 175, 55, 0.78);
  box-shadow: 0 0 24px rgba(212, 175, 55, 0.25), inset 0 0 18px rgba(26, 123, 181, 0.35);
}
.seal-logo img { width: 68%; height: 68%; object-fit: contain; }
.seal-logo.big { width: 148px; height: 148px; }

/* ---------- loader ---------- */
#loader { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 16px; background: radial-gradient(circle at 50% 38%, #142847, var(--bg) 65%); transition: opacity 0.6s; }
#loader.out { opacity: 0; pointer-events: none; }
.loader-title { font: 900 32px var(--font-display); letter-spacing: 0.26em; padding-left: 0.26em; color: #f8f2e4; }
.loader-sub { font: 600 11px var(--font); letter-spacing: 0.28em; color: var(--gold); margin-top: -8px; }
.loader-bar { width: min(320px, 70vw); height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--gold), var(--orange)); transition: width 0.25s; }
.loader-text { color: var(--muted); font-size: 13px; }

/* ---------- login ---------- */
#login {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; padding: 24px; pointer-events: none;
  background: linear-gradient(90deg, rgba(8, 17, 31, 0.9) 0%, rgba(8, 17, 31, 0.58) 42%, rgba(8, 17, 31, 0.05) 68%);
}
.login-card { pointer-events: auto; width: min(490px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; overflow-x: hidden; touch-action: pan-y; padding: 22px 24px 18px; margin-left: clamp(0px, 3vw, 56px); scrollbar-width: thin; }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.login-brand h1 { margin: 0; font: 900 26px var(--font-display); letter-spacing: 0.16em; color: #f8f2e4; }
.login-brand p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.login-brand b { color: var(--gold-soft); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 11px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); margin-bottom: 14px; }
.tab { border: 0; background: none; padding: 9px 6px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 12.5px; transition: all 0.15s; }
.tab.active { background: linear-gradient(135deg, rgba(26, 123, 181, 0.36), rgba(212, 175, 55, 0.22)); color: #fff; box-shadow: 0 0 0 1px var(--line-strong) inset; }
.tab-pane { display: none; }
.tab-pane.active { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
#lar-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 9px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select, textarea { width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: rgba(4, 10, 20, 0.55); outline: none; font-size: 13.5px; color: var(--text); transition: border-color 0.2s, box-shadow 0.2s; user-select: text; -webkit-user-select: text; }
textarea { resize: none; }
select option { background: #0c192d; color: #f3efe6; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.16); }

.sso-info { padding: 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: rgba(212, 175, 55, 0.08); font-size: 13px; display: flex; gap: 12px; align-items: center; }
.sso-info img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold); }
.sso-info .sso-meta { flex: 1; min-width: 0; }
.sso-switch { margin-left: auto; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; font-size: 11px; color: var(--muted); }
.sso-switch:hover { border-color: var(--gold); color: #fff; }

.section-title { margin: 14px 0 7px; font: 700 10.5px var(--font); letter-spacing: 0.16em; color: var(--gold-soft); text-transform: uppercase; }
.avatar-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.avatar-pick button { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); text-align: left; transition: all 0.18s; }
.avatar-pick button .ico { font-size: 18px; color: var(--gold); width: 22px; text-align: center; }
.avatar-pick button b { display: block; font-size: 12px; color: var(--text); }
.avatar-pick button small { display: block; font-size: 10px; color: var(--muted); }
.avatar-pick button.active, .avatar-pick button:hover { border-color: var(--gold); background: rgba(212, 175, 55, 0.14); }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.22); background: var(--c); position: relative; transition: transform 0.15s; }
.swatches button.active { border-color: #fff; transform: scale(1.14); box-shadow: 0 0 0 2px var(--gold); }
.swatches button:hover::after { content: attr(data-name); position: absolute; top: 36px; left: 50%; transform: translateX(-50%); font-size: 10px; white-space: nowrap; color: var(--muted); }

.login-error { margin-top: 12px; padding: 9px 12px; border-radius: 9px; background: rgba(226, 93, 109, 0.14); border: 1px solid rgba(226, 93, 109, 0.45); color: #ffc0c7; font-size: 12.5px; }
.btn-primary {
  width: 100%; margin-top: 16px; padding: 13px; border: 0; border-radius: 11px;
  font: 700 13.5px var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; color: #0a121f;
  background: linear-gradient(135deg, #e7c86a, #c79a2b);
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.32); transition: transform 0.15s, filter 0.2s;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:disabled { filter: grayscale(0.6) brightness(0.75); cursor: wait; }

.login-register-box { margin-top: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(26, 123, 181, 0.35); background: rgba(26, 123, 181, 0.08); display: grid; gap: 6px; text-align: center; font-size: 11.5px; color: var(--muted); }
.btn-register-link { display: inline-flex; align-items: center; justify-content: center; padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(236, 103, 27, 0.55); background: rgba(236, 103, 27, 0.14); color: #ffb585; font-weight: 700; font-size: 12px; text-decoration: none; }
.btn-register-link:hover { background: rgba(236, 103, 27, 0.24); }
.login-foot { margin-top: 10px; text-align: center; font-size: 11px; color: var(--muted); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-tl { position: absolute; top: 14px; left: 14px; display: flex; gap: 10px; align-items: flex-start; pointer-events: none; }
.hud-tl > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; font: 900 14px var(--font-display); letter-spacing: 0.18em; color: #f8f2e4; padding-top: 8px; }
.brand img { width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--gold); padding: 3px; background: rgba(8, 17, 31, 0.9); }
.room-chip { padding: 9px 14px; min-width: 220px; max-width: 390px; }
.room-name { font: 700 13px var(--font-display); letter-spacing: 0.05em; color: #f8f2e4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-meta { font-size: 11px; color: var(--gold-soft); margin-top: 5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status-pill { margin-left: 4px; padding: 2px 8px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font-size: 10.5px; font-weight: 600; color: var(--text); }
.status-pill:hover { border-color: var(--gold); }

.hud-tr { position: absolute; top: 14px; right: 14px; display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.hbtn { position: relative; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(12px); font-size: 15px; transition: all 0.18s; }
.hbtn span { font-size: 12px; font-weight: 600; }
.hbtn:hover { border-color: var(--gold); background: rgba(212, 175, 55, 0.14); }
.hbtn.on { border-color: var(--gold); background: rgba(212, 175, 55, 0.2); }
.hbadge { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--orange); color: #fff; font: 700 10px/17px var(--font); font-style: normal; padding: 0 4px; text-align: center; }
.hud-more { display: contents; }
.mobile-only { display: none !important; }
#btn-places { order: 1; }
#btn-matters { order: 2; }
#btn-map { order: 3; }
#btn-board { order: 4; }
#btn-online { order: 5; }
#btn-hub { order: 6; }
#btn-cam { order: 7; }
#btn-clean { order: 8; }
#btn-settings { order: 9; }
#btn-mobile-menu { order: 10; }
#btn-settings span { display: none; }

#stage-banner {
  position: absolute; z-index: 12; top: 64px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; padding: 8px 18px; border-radius: 26px;
  background: rgba(14, 26, 46, 0.9); border: 1px solid var(--line-strong); font: 700 12px var(--font); color: var(--gold-soft); max-width: min(56vw, 560px); overflow: hidden;
}
.stage-marquee { overflow: hidden; flex: 1; min-width: 0; display: flex; }
#stage-text { display: inline-block; white-space: nowrap; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); animation: pulse 1.4s infinite; flex: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(236, 103, 27, 0); } 100% { box-shadow: 0 0 0 0 rgba(236, 103, 27, 0); } }

#prompt { position: absolute; z-index: 8; bottom: calc(104px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; padding: 9px 17px; border-radius: 28px; background: var(--glass-strong); border: 1px solid var(--line-strong); font-size: 13px; font-weight: 600; cursor: pointer; animation: rise 0.2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

#screen-tools { position: absolute; z-index: 12; top: 106px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; }
#screen-tools button { padding: 7px 14px; border-radius: 20px; border: 1px solid var(--line-strong); background: var(--glass-strong); font-size: 12.5px; font-weight: 600; }
#screen-tools button:hover { background: rgba(212, 175, 55, 0.16); }
#screen-tools button.active { border-color: var(--blue); background: rgba(26, 123, 181, 0.25); }

#toasts { position: absolute; z-index: 22; top: 108px; left: 50%; transform: translateX(-50%); display: grid; gap: 7px; justify-items: center; pointer-events: none; }
.toast { padding: 9px 16px; border-radius: 11px; background: var(--glass-strong); border: 1px solid var(--line); font-size: 13px; animation: rise 0.25s ease-out; transition: opacity 0.4s; }
.toast.gold { border-color: var(--gold); color: var(--gold-soft); }
.toast.err { border-color: rgba(226, 93, 109, 0.7); color: #ffc0c7; }

.minimap-wrap { position: absolute; left: 14px; bottom: calc(14px + var(--safe-b)); width: 164px; height: 164px; border-radius: 50%; background: radial-gradient(circle, rgba(12, 24, 44, 0.9), rgba(6, 13, 26, 0.96)); border: 1.5px solid var(--line-strong); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55); overflow: hidden; pointer-events: none; }
#minimap { width: 100%; height: 100%; }
.minimap-n { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); font: 700 9px var(--font-display); color: var(--gold); }

.dock { position: absolute; z-index: 8; bottom: calc(14px + var(--safe-b)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 16px; }
.dbtn { position: relative; display: grid; justify-items: center; gap: 1px; width: 52px; height: 52px; padding-top: 6px; border-radius: 12px; border: 1px solid transparent; background: rgba(255, 255, 255, 0.03); transition: all 0.15s; }
.dbtn .i { font-size: 19px; line-height: 1.2; }
.dbtn small { font-size: 9.5px; color: var(--muted); font-weight: 600; }
.dbtn:hover { background: rgba(212, 175, 55, 0.12); border-color: var(--line-strong); }
.dbtn.on { background: rgba(56, 199, 127, 0.16); border-color: rgba(56, 199, 127, 0.65); }
.dbtn.on small { color: var(--ok); }
.dbtn.speaking { box-shadow: 0 0 18px rgba(56, 199, 127, 0.55); }
.dbtn.muted-x .i { filter: grayscale(1) opacity(0.65); }
.dbtn .badge { position: absolute; top: 4px; right: 6px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--orange); color: #fff; font: 700 9px/16px var(--font); font-style: normal; padding: 0 4px; }
.sep { width: 1px; height: 30px; background: var(--line); margin: 0 4px; }

#chat { position: absolute; z-index: 18; right: 14px; bottom: calc(14px + var(--safe-b)); width: min(380px, calc(100vw - 28px)); height: min(440px, 56vh); display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 6px 16px; font: 700 12px var(--font-display); letter-spacing: 0.08em; color: var(--gold-soft); }
.chat-log { flex: 1; overflow-y: auto; touch-action: pan-y; padding: 4px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; user-select: text; -webkit-user-select: text; scrollbar-width: thin; }
.msg { line-height: 1.42; word-wrap: break-word; }
.msg b { cursor: pointer; }
.msg .tag { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-right: 6px; vertical-align: 1px; }
.msg .tag.near { background: rgba(26, 123, 181, 0.25); color: #8ecdf7; }
.msg .tag.whisper { background: rgba(236, 103, 27, 0.22); color: #ffb382; }
.msg.sys { color: var(--muted); font-style: italic; font-size: 12px; }
.msg.host { color: #ffe7a8; background: rgba(212, 175, 55, 0.1); border-left: 3px solid var(--gold); padding-left: 6px; border-radius: 4px; }
.chat-foot { padding: 8px 10px 10px; border-top: 1px solid var(--line); display: grid; gap: 7px; }
.chat-modes { display: flex; gap: 4px; }
.chat-modes button { flex: 1; padding: 6px 4px; font-size: 11px; font-weight: 600; border-radius: 8px; border: 1px solid var(--line); background: none; color: var(--muted); }
.chat-modes button.active { color: #fff; border-color: var(--gold); background: rgba(212, 175, 55, 0.14); }
.chat-modes button[data-mode='whisper'].active { border-color: var(--orange); background: rgba(236, 103, 27, 0.16); }
#whisper-to { padding: 7px 10px; font-size: 12.5px; }
#chat-form { display: flex; gap: 6px; }
#chat-form input { padding: 9px 12px; min-width: 0; flex: 1; }
#chat-form button { flex: none; width: 44px; border-radius: 9px; border: 0; background: linear-gradient(135deg, #e7c86a, #c79a2b); color: #0a121f; font-weight: 700; }

#help { position: absolute; top: 96px; left: 50%; transform: translateX(-50%); padding: 14px 20px; display: grid; gap: 7px; justify-items: center; font-size: 12.5px; color: var(--muted); text-align: center; transition: opacity 0.6s; max-width: min(640px, calc(100vw - 32px)); }
#help b { font: 700 13px var(--font-display); color: var(--gold-soft); letter-spacing: 0.06em; }
#help .keys { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; justify-content: center; }

/* ---------- joystick mobile ---------- */
#joystick { position: absolute; z-index: 5; left: 20px; bottom: calc(24px + var(--safe-b)); width: 122px; height: 122px; border-radius: 50%; background: rgba(10, 21, 38, 0.6); border: 1px solid var(--line-strong); touch-action: none; }
#joystick .stick { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f0d788, #b58927); }
#mobile-actions { position: absolute; z-index: 5; right: 16px; bottom: calc(96px + var(--safe-b)); display: grid; gap: 10px; }
body.chat-open #mobile-actions { opacity: 0; pointer-events: none; }
#mobile-actions button { width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--glass); font: 700 17px var(--font); display: grid; place-content: center; }
#mobile-actions button small { font: 600 9px var(--font); color: var(--muted); }
#mobile-actions button.on { border-color: var(--gold); }

/* ---------- pannelli ---------- */
.panel { background: rgba(9, 18, 34, 0.95) !important; position: fixed; z-index: 24; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(500px, calc(100vw - 24px)); max-height: min(84vh, 780px); display: flex; flex-direction: column; animation: pop 0.2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(0.98); } }
.panel.right { left: auto; right: 14px; top: 68px; transform: none; max-height: calc(100vh - 200px); min-height: 200px; animation: slideIn 0.2s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateX(14px); } }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 18px; border-bottom: 1px solid var(--line); }
.panel-head b { font: 700 13px var(--font-display); letter-spacing: 0.08em; color: var(--gold-soft); }
.panel-body { padding: 14px 18px 18px; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; display: grid; grid-template-columns: minmax(0, 1fr); gap: 11px; scrollbar-width: thin; }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 13px; }
.set-row > span { color: var(--text); }
.set-row small { display: block; color: var(--muted); font-size: 11px; }
.set-row input[type='range'] { width: 145px; accent-color: var(--gold); padding: 0; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.14); transition: 0.2s; cursor: pointer; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: 0.2s; }
.switch input:checked + i { background: linear-gradient(90deg, var(--blue), var(--gold)); }
.switch input:checked + i::after { transform: translateX(20px); }

.btn { padding: 9px 13px; border-radius: 9px; border: 1px solid var(--line-strong); background: rgba(212, 175, 55, 0.08); font-size: 12.5px; font-weight: 600; transition: all 0.15s; }
.btn:hover { background: rgba(212, 175, 55, 0.18); }
.btn.gold { border-color: rgba(212, 175, 55, 0.72); background: rgba(212, 175, 55, 0.16); color: #f8e5a0; }
.btn.blue { border-color: rgba(26, 123, 181, 0.72); background: rgba(26, 123, 181, 0.18); color: #b7e3ff; }
.btn.danger { border-color: rgba(226, 93, 109, 0.6); background: rgba(226, 93, 109, 0.14); color: #ffc2c9; }
.btn.sm { padding: 6px 9px; font-size: 11.5px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

.online-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 11px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); min-width: 0; }
.online-item .av { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font: 700 12px var(--font-display); color: #0b1424; background: var(--c); border: 1px solid rgba(255, 255, 255, 0.35); }
.online-item .meta { flex: 1; min-width: 0; font-size: 11.5px; color: var(--muted); }
.online-item .meta b { display: block; color: var(--text); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-item .meta > span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-actions { display: flex; gap: 5px; flex: none; }
.verified { color: var(--gold); font-size: 12px; margin-left: 4px; }
.demo-pill { font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 6px; background: rgba(158, 176, 199, 0.18); color: var(--muted); margin-left: 5px; vertical-align: 1px; }
.online-group { font: 700 10.5px var(--font-display); letter-spacing: 0.12em; color: var(--gold-soft); margin-top: 4px; }

.profile-hero { display: flex; gap: 14px; align-items: center; }
.profile-hero .pic { width: 68px; height: 68px; border-radius: 50%; flex: none; background: var(--c) center/cover; border: 2px solid var(--gold); display: grid; place-items: center; font: 900 24px var(--font-display); color: #0a121f; }
.profile-hero h3 { margin: 0; font: 700 16px var(--font-display); }
.profile-hero .role { color: var(--gold-soft); font-size: 13px; font-weight: 600; margin-top: 3px; }
.profile-hero .city { color: var(--muted); font-size: 12px; margin-top: 2px; }
.profile-bio { font-size: 13px; line-height: 1.5; color: #d5dfec; padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line); user-select: text; }
.profile-stats { display: flex; gap: 7px; flex-wrap: wrap; }
.chip { font-size: 11.5px; padding: 4px 10px; border-radius: 18px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.24); }
.chip.gold { border-color: var(--line-strong); color: var(--gold-soft); }

.pick-grid { display: grid; gap: 7px; }
.pick-item { text-align: left; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.24); }
.pick-item:hover { border-color: var(--gold); background: rgba(212, 175, 55, 0.1); }
.pick-item .em { font-size: 20px; }
.pick-item .meta { flex: 1; font-size: 12px; color: var(--muted); }
.pick-item .meta b { display: block; color: var(--text); font-size: 13px; }
.count-pill { font: 700 11px var(--font); padding: 3px 8px; border-radius: 10px; background: rgba(56, 199, 127, 0.16); color: var(--ok); border: 1px solid rgba(56, 199, 127, 0.45); }

/* ---------- Bacheca Pareri & Domiciliazioni ---------- */
.board-form { display: grid; gap: 8px; padding: 11px; border-radius: 11px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); }
.board-post { display: grid; gap: 6px; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.24); }
.board-post-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.board-tag { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line-strong); color: var(--gold-soft); background: rgba(212, 175, 55, 0.12); }
.board-text { font-size: 13px; line-height: 1.45; color: #ece7db; user-select: text; }
.board-meta { font-size: 11px; color: var(--muted); }

/* ---------- etichette 3D (CSS2D) ---------- */
.nameplate { display: grid; justify-items: center; gap: 2px; transform: translateY(-6px); pointer-events: none; transition: opacity 0.25s; }
.nameplate .np { display: flex; align-items: center; gap: 5px; padding: 4px 10px 4px 8px; border-radius: 9px; background: rgba(8, 16, 30, 0.86); border: 1px solid color-mix(in srgb, var(--c) 65%, transparent); white-space: nowrap; }
.nameplate .np .mic { font-size: 11px; opacity: 0.4; }
.nameplate .np .mic.on { opacity: 1; }
.nameplate .np .mic.talk { opacity: 1; }
.nameplate .nm { font: 700 12px var(--font); color: #f8f3e8; }
.nameplate .vf { color: var(--gold); font-size: 11px; }
.nameplate .dm { font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 4px; background: rgba(255,255,255,0.12); color: #cfd9e6; }
.nameplate .sub { font: 500 10px var(--font); color: #cbd8e8; text-shadow: 0 1px 3px #000; white-space: nowrap; }
.nameplate .st-line { display: flex; align-items: center; gap: 4px; font: 600 9.5px var(--font); color: #e2dccf; background: rgba(8, 16, 30, 0.72); padding: 1px 7px; border-radius: 8px; }
.nameplate .st-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.nameplate .stg { font: 700 9px var(--font-display); letter-spacing: 0.08em; padding: 2px 8px; border-radius: 8px; color: #160d02; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.bubble { max-width: 240px; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: rgba(248, 244, 234, 0.96); color: #0c1728; font: 500 12.5px/1.35 var(--font); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45); border: 2px solid var(--c); pointer-events: none; transform: translate(38px, -10px); animation: bubbleIn 0.25s ease-out; word-wrap: break-word; transition: opacity 0.5s; }
.bubble.whisper { background: rgba(255, 240, 224, 0.96); }
@keyframes bubbleIn { from { opacity: 0; transform: translate(38px, 0) scale(0.88); } }

/* ---------- transizione ---------- */
#transition { position: fixed; inset: 0; z-index: 40; display: grid; place-content: center; justify-items: center; gap: 18px; background: radial-gradient(circle, rgba(18, 34, 62, 0.95), rgba(6, 12, 24, 0.99) 70%); animation: fadeIn 0.3s; }
#transition.out { opacity: 0; transition: opacity 0.45s; }
@keyframes fadeIn { from { opacity: 0; } }
.tr-seal { width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center; font-size: 46px; border: 2.5px solid var(--gold); background: rgba(12, 24, 44, 0.9); box-shadow: 0 0 36px rgba(212, 175, 55, 0.35); }
.tr-text { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 0 20px; }
.tr-text small { font: 700 11px var(--font); letter-spacing: 0.26em; color: var(--gold); text-transform: uppercase; }
.tr-text b { font: 900 24px var(--font-display); letter-spacing: 0.05em; color: #f8f2e4; }
.tr-text span { color: var(--muted); font-size: 13px; }

/* ---------- mappa ---------- */
#map-overlay { position: fixed; inset: 0; z-index: 25; background: #07101d; display: flex; }
#leaflet-map { flex: 1; height: 100%; background: #081222; }
.map-side { position: absolute; z-index: 500; left: 14px; top: 14px; bottom: 14px; width: min(360px, calc(100vw - 28px)); display: flex; flex-direction: column; gap: 9px; padding: 14px; }
.map-head { display: flex; justify-content: space-between; align-items: flex-start; }
.map-head b { font: 700 14px var(--font-display); letter-spacing: 0.05em; display: block; color: var(--gold-soft); }
.map-head small { color: var(--muted); font-size: 11.5px; }
.map-filters { display: flex; flex-wrap: wrap; gap: 5px; }
.map-filters button { font-size: 11px; padding: 5px 9px; border-radius: 15px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.28); color: var(--muted); font-weight: 600; }
.map-filters button.active { color: #fff; border-color: var(--c, var(--gold)); background: color-mix(in srgb, var(--c, var(--gold)) 22%, transparent); }
.map-views { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 3px; border-radius: 9px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); }
.map-views button { border: 0; background: none; padding: 6px 4px; border-radius: 7px; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.map-views button.active { background: rgba(212, 175, 55, 0.22); color: #fff; }
.map-count { font-size: 11px; color: var(--muted); }
.map-list { flex: 1; overflow-y: auto; touch-action: pan-y; display: grid; gap: 5px; align-content: start; scrollbar-width: thin; }
.map-list .pick-item { padding: 8px 10px; }
.leaflet-container { font-family: var(--font); background: #081222; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: rgba(9, 18, 34, 0.96); color: var(--text); border: 1px solid var(--line-strong); }
.leaflet-popup-content { margin: 14px 16px; min-width: 220px; }
.leaflet-popup-close-button { color: var(--muted) !important; }
.pop h4 { margin: 0 0 4px; font: 700 14px var(--font-display); color: var(--gold-soft); }
.pop p { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.pop .btn { width: 100%; }
.map-pin { position: relative; }
.map-pin i { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.6); }
.map-pin b { position: absolute; top: -11px; left: 10px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--ok); color: #05160e; font: 700 10px/18px var(--font); text-align: center; padding: 0 4px; }

/* ---------- schermo max / vista pulita / show ---------- */
#screen-max { position: fixed; inset: 0; z-index: 80; background: #000; display: grid; place-items: center; }
#screen-max iframe, #screen-max video { width: 100%; height: 100%; border: 0; background: #000; object-fit: contain; }
#screen-max .sm-close { position: absolute; top: 14px; right: 14px; z-index: 2; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--line-strong); background: rgba(8, 17, 31, 0.88); font-size: 13px; font-weight: 600; }

body.clean-view #labels { display: none; }
body.clean-view #hud > *:not(.hud-tr):not(#joystick):not(#toasts) { display: none !important; }
body.clean-view .hud-tr > *:not(.hud-more) { display: none !important; }
body.clean-view .hud-more { display: contents !important; }
body.clean-view .hud-more > *:not(#btn-clean) { display: none !important; }
body.clean-view #btn-clean { display: flex !important; opacity: 0.55; }
body.clean-view #btn-clean:hover { opacity: 1; }
#screen-tools, #stage-banner { transition: opacity 0.6s; }
body.ui-idle #screen-tools, body.ui-idle #stage-banner { opacity: 0; pointer-events: none; }
#btn-sit.on { background: rgba(212, 175, 55, 0.18); border-color: var(--gold); }

body.show-mode .hud-tl, body.show-mode .hud-tr, body.show-mode .dock, body.show-mode .minimap-wrap,
body.show-mode #prompt, body.show-mode #chat, body.show-mode #stage-banner, body.show-mode #screen-tools,
body.show-mode #help, body.show-mode #mobile-actions, body.show-mode #labels { display: none !important; }
#show-bar { position: absolute; left: 50%; bottom: calc(12px + var(--safe-b)); transform: translateX(-50%); width: min(920px, calc(100vw - 24px)); display: grid; gap: 6px; }
#sb-log { display: flex; flex-direction: column; justify-content: flex-end; gap: 3px; max-height: 150px; overflow: hidden; padding: 0 6px; pointer-events: none; }
.sb-msg { align-self: flex-start; max-width: 100%; font-size: 13.5px; line-height: 1.35; padding: 4px 10px; border-radius: 10px; background: rgba(8, 17, 31, 0.78); color: #ece7db; border: 1px solid var(--line); }
.sb-msg b { color: var(--gold-soft); margin-right: 4px; }
.sb-msg.old { opacity: 0.35; }
.sb-row { display: flex; gap: 6px; align-items: center; padding: 6px; border-radius: 12px; background: rgba(8, 17, 31, 0.85); border: 1px solid var(--line); backdrop-filter: blur(10px); }
.sb-host { font: 700 11px var(--font-display); white-space: nowrap; padding: 0 6px; }
.sb-modes { display: flex; gap: 3px; }
.sb-modes button { padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.sb-modes button.active { color: #fff; border-color: var(--gold); background: rgba(212, 175, 55, 0.16); }
#sb-to { width: 140px; padding: 7px 8px; font-size: 12px; }
#sb-form { flex: 1; display: flex; gap: 5px; min-width: 120px; }
#sb-form input { padding: 8px 11px; }
#sb-form button { width: 40px; border-radius: 8px; border: 0; background: linear-gradient(135deg, #e7c86a, #c79a2b); color: #0a121f; font-weight: 700; }
.sb-btn { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); font-size: 12px; font-weight: 600; }
#show-host { position: absolute; top: 12px; left: 12px; display: grid; gap: 6px; padding: 10px; width: 196px; }
.sh-title { font: 700 10px var(--font-display); letter-spacing: 0.08em; color: var(--gold); }
#show-host button { padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line-strong); background: rgba(212, 175, 55, 0.1); font-size: 12.5px; font-weight: 600; text-align: left; }
#show-host button.danger { border-color: rgba(226, 93, 109, 0.6); background: rgba(226, 93, 109, 0.14); }

@media (max-width: 1320px) {
  .hbtn { padding: 0 10px; }
  .hbtn span { display: none; }
  .hbtn #online-count { display: inline; }
  .room-chip { min-width: 180px; max-width: calc(100vw - 560px); }
}

@media (max-width: 1020px) {
  .brand span { display: none; }
  .room-chip { max-width: calc(100vw - 440px); }
}

@media (max-width: 820px) {
  .mobile-only { display: flex !important; }
  #login { background: linear-gradient(180deg, rgba(8, 17, 31, 0.2), rgba(8, 17, 31, 0.92) 45%); align-items: flex-end; justify-content: center; padding: 10px; }
  .login-card { margin: 0 auto; padding: 16px; max-height: 75vh; }
  .row2 { grid-template-columns: 1fr; }

  /* Top bar compatta su singola riga senza sovrapposizioni */
  .hud-tl { left: 8px; top: 8px; gap: 6px; align-items: center; max-width: calc(100vw - 168px); }
  .brand { padding-top: 0; }
  .brand img { width: 30px; height: 30px; }
  .brand span { display: none; }
  .room-chip { min-width: 0; max-width: calc(100vw - 208px); padding: 5px 9px; border-radius: 11px; }
  .room-name { font-size: 11.5px; }
  .room-meta { margin-top: 2px; font-size: 10.5px; flex-wrap: nowrap; white-space: nowrap; }
  .room-sub, #net-state, #btn-my-status { display: none; }

  /* Top-right: 3 pulsanti compatti (Mappa, Colleghi, Menu) su 1 riga */
  .hud-tr { right: 8px; top: 8px; gap: 5px; flex-wrap: nowrap; max-width: none; align-items: center; }
  .hud-tr > .hbtn { height: 38px; padding: 0 9px; border-radius: 10px; font-size: 15px; order: initial; }
  .hud-tr > .hbtn span { display: none; }
  .hud-tr > .hbtn #online-count { display: inline; font-size: 12px; }

  /* Menu comandi a scomparsa aperto da ☰ */
  .hud-more { display: none; }
  .hud-tr.menu-open .hud-more {
    position: fixed;
    top: 54px;
    right: 8px;
    width: min(300px, calc(100vw - 16px));
    z-index: 26;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    padding: 10px;
    border-radius: 14px;
    background: rgba(9, 18, 34, 0.96);
    border: 1px solid var(--line-strong);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.68);
    animation: slideIn 0.16s ease-out;
  }
  .hud-tr.menu-open .hud-more .hbtn {
    order: initial;
    width: 100%;
    height: 42px;
    padding: 0 10px;
    justify-content: flex-start;
    gap: 8px;
    font-size: 15px;
    border-radius: 10px;
  }
  .hud-tr.menu-open .hud-more .hbtn span {
    display: inline !important;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hud-tr.menu-open .hud-more .hbtn.full-span {
    grid-column: 1 / -1;
    justify-content: center;
    height: 36px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
  }

  /* Minimappa discreta sotto la top bar a destra, nascosta con menu/pannelli/chat aperti */
  .minimap-wrap { width: 74px; height: 74px; left: auto; right: 8px; top: 54px; bottom: auto; opacity: 0.88; transition: opacity 0.18s; }
  body.menu-open .minimap-wrap,
  body.panel-open .minimap-wrap,
  body.chat-open .minimap-wrap { opacity: 0; pointer-events: none; }

  /* Banner e toast ben posizionati sotto la top bar */
  #stage-banner { top: 54px; max-width: calc(100vw - 98px); padding: 6px 12px; font-size: 11px; }
  #toasts { top: 56px; max-width: calc(100vw - 20px); }
  #screen-tools { top: 96px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 20px); }

  /* Barra reazioni compatta: tutti gli 8 pulsanti visibili anche su 360px */
  .dock {
    bottom: calc(8px + var(--safe-b));
    max-width: calc(100vw - 12px);
    overflow-x: auto;
    scrollbar-width: none;
    padding: 4px;
    gap: 2px;
    border-radius: 13px;
  }
  .dock::-webkit-scrollbar { display: none; }
  .dock .sep { display: none; }
  .dock .dbtn { flex: none; width: 41px; height: 44px; padding-top: 4px; border-radius: 10px; }
  .dock .dbtn .i { font-size: 16px; }
  .dock .dbtn small { font-size: 8.5px; }

  /* Navigatore joystick e pulsanti Corri/Azione ben SOPRA la barra delle reazioni */
  #joystick {
    left: 12px;
    bottom: calc(70px + var(--safe-b));
    width: 104px;
    height: 104px;
  }
  #joystick .stick {
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
  }
  #mobile-actions {
    right: 12px;
    bottom: calc(70px + var(--safe-b));
    gap: 8px;
  }
  #mobile-actions button { width: 50px; height: 50px; font-size: 15px; }
  body.chat-open #joystick,
  body.panel-open #joystick,
  body.panel-open #mobile-actions,
  body.menu-open #joystick,
  body.menu-open #mobile-actions { opacity: 0; pointer-events: none; }

  #prompt { bottom: calc(68px + var(--safe-b)); max-width: calc(100vw - 144px); padding: 7px 12px; font-size: 12px; }

  /* Pannelli e Chat incorniciati tra top bar (54px) e dock inferiore (64px) */
  .panel,
  .panel.right {
    left: 8px;
    right: 8px;
    top: 54px;
    bottom: calc(64px + var(--safe-b));
    width: auto;
    max-height: none;
    transform: none;
    animation: slideIn 0.18s ease-out;
  }
  .panel-head { padding: 12px 12px 9px 14px; }
  .panel-body { padding: 12px 12px 16px; gap: 9px; }

  /* Lista Colleghi Online: layout a 2 righe (testo a tutta larghezza + barra azioni sotto) */
  .online-item {
    flex-wrap: wrap;
    align-items: flex-start;
    row-gap: 8px;
    padding: 10px 11px;
  }
  .online-item .av { width: 36px; height: 36px; }
  .online-item .meta { flex: 1 1 calc(100% - 48px); min-width: 0; }
  .online-item .meta b,
  .online-item .meta > span { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.32; }
  .online-item .online-actions { flex: 1 0 100%; display: flex; gap: 6px; padding-top: 2px; }
  .online-item .online-actions .btn { flex: 1; text-align: center; padding: 7px 8px; font-size: 12px; }
  .online-item .online-actions .btn[data-msg] { flex: 0 0 auto; min-width: 44px; }

  .pick-item .meta { min-width: 0; }
  .pick-item .meta b { line-height: 1.3; }

  #chat { right: 8px; left: 8px; width: auto; top: 54px; bottom: calc(64px + var(--safe-b)); height: auto; }
  .map-side { top: auto; height: 46vh; left: 8px; right: 8px; bottom: 8px; width: auto; }
  #help { display: none !important; }
}

@media (max-width: 370px) {
  .dock .dbtn { width: 38px; height: 42px; }
  .room-chip { max-width: calc(100vw - 182px); }
}
