/* Vacwm Cup 2.0 - tema nero con dettagli bianchi */
:root {
  color-scheme: dark;
  --bg: #000;
  --panel: #0b0b0b;
  --panel-2: #141414;
  --line: #262626;
  --line-2: #3a3a3a;
  --text: #fff;
  --muted: #a1a1a1;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #3a3a3a transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
::selection { background: #fff; color: #000; }

/* ---------- barre di scorrimento ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #5c5c5c; background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- barra in alto ---------- */
.topbar { height: 64px; flex: none; display: flex; align-items: center; gap: 20px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, 0.92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; }
.brand img { width: 36px; height: 36px; object-fit: contain; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6)); }
.grow { flex: 1; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.userwrap { position: relative; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); font: inherit; color: var(--text); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.chip:hover { border-color: var(--line-2); background: var(--panel-2); }
.chip .name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 180px; padding: 6px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); box-shadow: 0 14px 38px rgba(0, 0, 0, 0.75); z-index: 40; display: flex; flex-direction: column; gap: 2px; animation: pop 0.12s ease-out; }
.menu-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.menu-item:hover, .menu-item:focus-visible { background: #1a1a1a; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }

/* ---------- bottoni, etichette ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-weight: 600; font-size: 14px; transition: background 0.15s, border-color 0.15s, transform 0.05s; }
.btn:hover { background: var(--panel-2); border-color: #5c5c5c; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #fff; border-color: #fff; color: #000; }
.btn.primary:hover { background: #e4e4e4; border-color: #e4e4e4; }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: #ef4444; border-color: #ef4444; color: #fff; }
.btn.danger-solid:hover { background: #dc2626; border-color: #dc2626; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.demo-menu { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); color: #d4d4d4; }
.tag.ok { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.08); }
.tag.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); }
.muted { color: var(--muted); }
.avatar { flex: none; position: relative; border-radius: 50%; overflow: hidden; display: grid; place-items: center; font-weight: 800; color: #fff; background: #3a3a3a; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.search, .field { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; font-size: 14px; }
.search::placeholder { color: var(--muted); }
.search:focus, .field:focus { outline: none; border-color: #fff; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 11px 18px; border-radius: 10px; background: #111; border: 1px solid var(--line-2); font-size: 14px; font-weight: 600; z-index: 120; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.7); }
.toast.err { border-color: var(--danger); }

/* ---------- finestra di conferma a centro schermo ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.74); backdrop-filter: blur(2px); animation: fade 0.12s ease-out; }
.modal { width: min(430px, 100%); padding: 24px; border: 1px solid var(--line-2); border-radius: 16px; background: var(--panel); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.85); animation: pop 0.14s ease-out; }
.modal h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.modal p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
@keyframes fade { from { opacity: 0; } }

/* ---------- tendina (menu a discesa) ---------- */
.dd { position: relative; display: inline-block; }
.dd-btn .dd-caret { font-size: 10px; opacity: 0.7; }
.dd-panel { position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; width: 270px; padding: 8px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); box-shadow: 0 16px 44px rgba(0, 0, 0, 0.8); animation: pop 0.12s ease-out; }
.dd-search { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 13px; }
.dd-search:focus { outline: none; border-color: #fff; }
.dd-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 250px; overflow-y: auto; }
.dd-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.dd-item.active { background: #1c1c1c; }
.dd-item .dot { width: 10px; height: 10px; border-radius: 50%; background: #6b6b6b; flex: none; }
.dd-empty { padding: 12px 10px; color: var(--muted); font-size: 13px; }

/* ---------- pagina della mappa ---------- */
.session { flex: 1; display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: 0; }
.session > * { min-width: 0; }
.side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; height: calc(100vh - 64px); position: sticky; top: 64px; }
.side-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-height: 0; flex: 1; }
.counter { text-align: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.counter small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; margin-bottom: 4px; }
.counter b { font-size: 30px; font-weight: 800; }
.counter span { color: var(--muted); font-size: 16px; font-weight: 600; }
.counter .sub { display: block; margin-top: 4px; font-size: 12px; font-weight: 500; letter-spacing: 0; }
.players { list-style: none; margin: 0 -6px 0 0; padding: 0 6px 0 0; overflow-y: auto; flex: 1; min-height: 80px; }
.player { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.player:hover { background: var(--panel-2); }
.player.me { background: #151515; box-shadow: inset 2px 0 0 #fff; }
.player .info { flex: 1; min-width: 0; }
.player .pname { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .ptime { display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; padding: 2px 7px; border-radius: 6px; background: #1a1a1a; color: #d4d4d4; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.player.pending .ptime { background: transparent; border: 1px dashed var(--line-2); color: var(--muted); font-weight: 600; }
.player .ed, .player .x { border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 6px; }
.player .x:hover { color: var(--danger); background: rgba(248, 113, 113, 0.12); }
.player .ed:hover { color: #fff; background: #222; }
.player .ed.on { color: #000; background: #fff; }
.player.target { box-shadow: inset 0 0 0 1px #fff; background: #151515; }
.no-players { color: var(--muted); font-size: 13px; padding: 16px 8px; text-align: center; line-height: 1.5; }
.stack { display: flex; flex: none; }
.stack .avatar { border: 2px solid var(--bg); }
.stack .avatar + .avatar { margin-left: -10px; }
.admin-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--panel); }
.admin-box summary { cursor: pointer; font-size: 12px; font-weight: 700; color: #d4d4d4; letter-spacing: 0.06em; }
.admin-box .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.admin-box .grid .wide { grid-column: 1 / -1; }

.stage { display: flex; align-items: flex-start; justify-content: center; gap: 16px; padding: 20px; min-width: 0; }
.mapwrap { position: relative; flex: 0 1 auto; width: min(100%, calc(100vh - 104px)); aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #0d2a40; user-select: none; -webkit-user-select: none; }
.mapwrap img.map { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; -webkit-user-drag: none; }
.mapwrap.editing { cursor: crosshair; touch-action: none; }
.mapwrap.editing img.map { filter: brightness(0.5); }
.mapwrap.editing.dragging img.map { filter: none; }
.drag-box { position: absolute; pointer-events: none; border: 2px dashed #fff; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5); }
.drag-box.bad { border-color: #ff6b6b; background: rgba(239, 68, 68, 0.18); }
.shape-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.area-shape { fill: #d6d6d6; fill-opacity: 0.38; stroke: #474747; stroke-width: 3; stroke-linejoin: miter; vector-effect: non-scaling-stroke; }
.preview-shape { fill: #fff; fill-opacity: 0.2; stroke: #fff; stroke-width: 2.5; stroke-dasharray: 7 5; vector-effect: non-scaling-stroke; }
.preview-shape.bad { fill: #ef4444; fill-opacity: 0.22; stroke: #ff8a8a; }
.pins { position: absolute; inset: 0; pointer-events: none; }
.duo-pin { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px; z-index: 2; }
.duo-pill { display: flex; align-items: center; gap: 0.6em; padding: 0.3em 0.9em 0.3em 0.3em; border: 1px solid #3a3a3a; border-radius: 999px; background: rgba(0, 0, 0, 0.9); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); min-width: 0; overflow: hidden; pointer-events: auto; cursor: pointer; transition: border-color 0.12s; }
.duo-pill:hover { border-color: #fff; }
.mapwrap.editing .duo-pill { pointer-events: none; }
.duo-pill .avatar { border: 0; }
.duo-pill .pname { color: #fff; font-size: 1em; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; line-height: 1.2; }
.duo-x { color: #fff; font-weight: 900; font-size: 1.5em; line-height: 1; text-shadow: 0 1px 4px #000, 0 0 8px #000; pointer-events: none; }
.duo-pin.pulse { animation: pinpulse 0.7s ease-in-out 3; z-index: 6; }
@keyframes pinpulse { 50% { transform: translate(-50%, -50%) scale(1.3); } }
.hint { pointer-events: none; position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 700; background: rgba(0, 0, 0, 0.85); border: 1px solid var(--line-2); backdrop-filter: blur(6px); white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.hint.locked { background: #000; border-color: #3a3a3a; color: #fff; }

/* finestra con i nomi della duo */
.duo-popup { position: absolute; z-index: 12; width: max-content; min-width: 190px; max-width: min(340px, calc(100% - 16px)); padding: 12px 34px 12px 12px; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.8); animation: pop 0.12s ease-out; }
.popup-row { display: flex; align-items: center; gap: 10px; }
.popup-name { font-weight: 700; font-size: 14px; line-height: 1.25; overflow-wrap: anywhere; }
.popup-x { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--muted); font-size: 18px; line-height: 1; }
.popup-x:hover { color: #fff; background: #1c1c1c; }

/* tasto "Modifica zona" a destra della mappa */
.tools { flex: 0 0 196px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 84px; }
.edit-btn { width: 100%; justify-content: flex-start; gap: 10px; padding: 12px 14px; font-weight: 700; }
.edit-btn .edit-ic { font-size: 16px; line-height: 1; }
.edit-btn.on { background: #fff; border-color: #fff; color: #000; }
.edit-btn.on:hover { background: #e4e4e4; }
.tools-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ---------- schermate di accesso ---------- */
.gate { margin: auto; max-width: 460px; padding: 40px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gate h1 { margin: 0; font-size: 26px; }
.gate p { margin: 0; color: var(--muted); line-height: 1.55; }
.session > .gate { grid-column: 1 / -1; }

/* ---------- dashboard ---------- */
.dash { width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px; display: grid; gap: 18px; }
.dash h1 { margin: 0; font-size: 26px; }
.dash .lead { margin: 6px 0 0; color: var(--muted); line-height: 1.55; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 18px; }
.panel h2 { margin: 0 0 4px; font-size: 17px; }
.panel .sub { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.status { font-size: 13px; font-weight: 600; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.perm-group { margin-top: 18px; }
.perm-group h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.1em; color: #d4d4d4; }
.perm { display: grid; grid-template-columns: minmax(180px, 1fr) 2fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.perm .what b { display: block; font-size: 14px; }
.perm .what span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); font-size: 13px; font-weight: 600; }
.rchip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.rchip button { border: 0; background: none; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; border-radius: 6px; }
.rchip button:hover { color: var(--danger); }
.rchip.fixed { padding-right: 10px; opacity: 0.9; }
.notice { padding: 12px 14px; border-radius: 10px; background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.3); color: #fde68a; font-size: 13px; line-height: 1.5; margin-bottom: 8px; }
.savebar { position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; justify-content: flex-end; padding: 12px 0 0; margin-top: 8px; background: linear-gradient(transparent, var(--panel) 40%); }
.duo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.pick-list, .duo-list { list-style: none; margin: 12px 0 0; padding: 0 6px 0 0; max-height: 440px; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.pick:hover { background: var(--panel-2); }
.pick.selected { border-color: #fff; background: #151515; }
.pick.taken { opacity: 0.45; cursor: not-allowed; }
.pick .nm { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duo-item { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); margin-bottom: 8px; }
.duo-item .who { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.duo-item .who small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; margin-top: 2px; }
.pickbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- telefono ---------- */
@media (max-width: 860px) {
  .topbar { padding: 0 12px; gap: 10px; overflow: visible; }
  .brand { font-size: 16px; white-space: nowrap; gap: 8px; }
  .brand img { width: 30px; height: 30px; }
  .userbox { gap: 6px; min-width: 0; }
  .demo-menu { display: none; }
  .chip .name { max-width: 90px; }
  .session { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); order: 2; }
  .stage { order: 1; padding: 10px; flex-direction: column; align-items: stretch; gap: 10px; }
  .mapwrap { width: 100%; }
  .tools { flex: none; width: 100%; position: static; order: -1; flex-direction: row; align-items: center; }
  .tools .edit-btn { width: auto; flex: none; }
  .players { max-height: 320px; }
  .hint { font-size: 11px; padding: 6px 10px; bottom: 8px; }
  .perm { grid-template-columns: 1fr; }
  .duo-grid { grid-template-columns: 1fr; }
  .dash { padding: 14px; }
}

/* strumenti staff nella colonna a destra della mappa */
.staff-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.staff-box .staff-title { font-size: 11px; font-weight: 700; letter-spacing: 0.1em; color: #d4d4d4; margin-bottom: 2px; }
.staff-box .btn { width: 100%; }
#edit-box { display: flex; flex-direction: column; gap: 10px; }
@media (max-width: 860px) { .tools { flex-direction: column; align-items: stretch; } .tools .edit-btn { width: 100%; } }
