/* Sock Monkey RP theme: night-sky indigo, neon purple/magenta, cyan, loading-screen gold (#FCD376) */
:root {
  --bg: #0b0a1d; --panel: #141230; --line: #2b2656; --text: #eeeaff; --muted: #9b94c9;
  --accent: #b14cff; --accent2: #ff4fd8; --cyan: #3fd0ff; --gold: #fcd376;
  --sel: #2a1f55; --ok: #3be8a0; --warn: #fcd376; --bad: #ff5c7a; --radius: 10px;
  --brand-grad: linear-gradient(90deg, #b14cff, #ff4fd8);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: radial-gradient(1200px 600px at 80% -10%, #2a1460 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #0d2a5c 0%, transparent 55%), var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.muted { color: var(--muted); }
.btn { display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 8px; text-decoration: none; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-discord { background: var(--brand-grad); border: 0; font-weight: 700; padding: 12px 22px; box-shadow: 0 0 18px #b14cff66; }
.btn-discord:hover { box-shadow: 0 0 26px #ff4fd899; }

/* login */
body.login { display: grid; place-items: center; padding: 16px; }
.login-card { background: #141230e6; border: 1px solid var(--line); border-radius: 16px; padding: 28px 32px 32px; box-shadow: 0 0 40px #b14cff33, 0 0 0 1px #b14cff22 inset; max-width: 420px; width: 100%; text-align: center; }
.login-card h1 { margin: 6px 0 8px; background: linear-gradient(90deg, #3fd0ff, #b14cff 45%, #ff4fd8 70%, #fcd376); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-logo { width: 168px; height: 168px; border-radius: 50%; filter: drop-shadow(0 0 18px #b14cff88); }
.err { background: #3a1d20; border: 1px solid var(--bad); color: #ffb4b6; padding: 10px; border-radius: 8px; }

/* app */
.top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid transparent; border-image: var(--brand-grad) 1; background: #141230f2; flex-wrap: wrap; }
.top h1 { font-size: 16px; margin: 0; display: flex; align-items: center; gap: 8px; }
.top h1 img { width: 30px; height: 30px; border-radius: 50%; box-shadow: 0 0 10px #b14cff88; }
.srv select { margin-left: 6px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.spacer { flex: 1; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.bad { color: var(--bad); border-color: var(--bad); }

.layout { display: grid; grid-template-columns: 300px 1fr; height: calc(100% - 53px); min-height: 0; }
.side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side input { margin: 12px; padding: 8px 10px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 0 12px 8px; }
#players { list-style: none; margin: 0; padding: 0 6px 12px; overflow-y: auto; }
#players li { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
#players li:hover { background: #1d1940; }
#players li.on { background: var(--sel); }
#players .pid { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 34px; }
#players .pname { flex: 1; min-width: 0; }
#players .pname b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#players .pname small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
#players .ping { font-size: 12px; color: var(--muted); }
#players li.focus { outline: 1px solid #4c8dff; outline-offset: -1px; }
#players .add { flex: none; font: inherit; font-size: 11px; padding: 3px 8px; border-radius: 6px; cursor: pointer; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
#players .add:hover { border-color: var(--accent); }
#players .add.is-on { background: #3a2f14; border-color: var(--gold); color: var(--gold); }
.tile .label b { cursor: pointer; }
.tile .label b:hover { text-decoration: underline; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: none; }
.dot.live { background: var(--ok); } .dot.wait { background: var(--warn); } .dot.err { background: var(--bad); }

.wall { position: relative; padding: 12px; overflow-y: auto; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); align-content: start; }
.empty[hidden], .toast[hidden] { display: none; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); pointer-events: none; }
.tile { position: relative; background: #000; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile .label { position: absolute; left: 0; right: 0; top: 0; display: flex; gap: 8px; align-items: center; padding: 6px 8px; background: linear-gradient(#000c, #0000); font-size: 13px; }
.tile .label b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .label .x { margin-left: auto; background: #0008; border: 1px solid #fff3; color: #fff; border-radius: 6px; cursor: pointer; padding: 0 7px; font: inherit; }
.tile .state { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
.tile.live .state { display: none; }
.tile:fullscreen { border: 0; border-radius: 0; }

/* views */
.views { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.views button { background: transparent; color: var(--muted); border: 0; padding: 5px 12px; cursor: pointer; font: inherit; }
.views button.on { background: var(--sel); color: var(--text); }
.content { min-height: 0; min-width: 0; display: grid; position: relative; grid-template-rows: minmax(0, 1fr); }
.content.view-wall { grid-template-columns: 1fr; } .content.view-wall .map-pane { display: none; }
.content.view-map { grid-template-columns: 1fr; } .content.view-map .wall { display: none; }
.content.view-split { grid-template-columns: 1fr 1fr; }
.content.view-split .wall { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* map */
.map-pane { position: relative; min-height: 0; border-right: 1px solid var(--line); }
#map { position: absolute; inset: 0; background: #000; }
.legend { position: absolute; left: 10px; bottom: 10px; z-index: 500; display: flex; flex-wrap: wrap; gap: 10px; background: #000b; padding: 6px 10px; border-radius: 8px; font-size: 12px; max-width: calc(100% - 20px); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #000; }
.lg.pol { background: #4c8dff; } .lg.ems { background: #ff5c5c; } .lg.oth { background: #f2f2f2; }
.lg.watch { background: transparent; border-color: var(--gold); } .lg.veh { display: none; } .lg.down { background: #777; }
.toast { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 2000; background: var(--sel); border: 1px solid var(--accent); padding: 6px 12px; border-radius: 8px; font-size: 13px; }

.lw-mk { position: relative; width: 32px; height: 32px; }
.lw-mk .badge { position: absolute; inset: 2px; border-radius: 50%; background: var(--c, #f2f2f2); border: 2px solid #111; box-shadow: 0 0 0 1.5px #fff, 0 1px 4px #000a; display: grid; place-items: center; }
.lw-mk .ic { width: 64%; height: 64%; display: block; }
.lw-mk .ic path { fill: #fff; }
.lw-mk.j-oth .ic path { fill: #111; }
.lw-mk .dir { position: absolute; left: 50%; top: 50%; width: 0; height: 0; margin-left: -5px; margin-top: -21px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid #fff; transform-origin: 5px 21px; filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 1px #000); }
.lw-mk.watch .badge { box-shadow: 0 0 0 3px var(--gold), 0 0 8px 2px #fcd37699; }
.lw-mk.down .badge { background: #6b6b6b; }
.lw-mk.down .ic path { fill: #ddd; }
.lw-mk.down .dir { display: none; }
.lw-mk.inst .badge { border-style: dashed; opacity: .55; }
.lw-anim .lw-mk-wrap { transition: transform 1.9s linear; }
.leaflet-tooltip.lw-tip { background: #171a21; color: var(--text); border: 1px solid var(--line); box-shadow: none; font-size: 12px; }
.leaflet-tooltip.lw-tip::before { display: none; }
.leaflet-container { font: inherit; }
.tile .label .loc { background: #0008; border: 1px solid #fff3; color: #fff; border-radius: 6px; cursor: pointer; padding: 0 6px; font: inherit; }

/* ---------- phone layout: one panel at a time + bottom tab bar ---------- */
.mtabs { display: none; }
.tile .label .fs { background: #0008; border: 1px solid #fff3; color: #fff; border-radius: 6px; cursor: pointer; padding: 0 6px; font: inherit; }
.leaflet-popup.lw-pop .leaflet-popup-content-wrapper, .leaflet-popup.lw-pop .leaflet-popup-tip { background: #171a21; color: var(--text); border: 1px solid var(--line); box-shadow: 0 4px 16px #000a; }
.leaflet-popup.lw-pop .leaflet-popup-content { margin: 10px 12px; font-size: 13px; line-height: 1.4; }
.leaflet-popup.lw-pop .pop-btn { margin-top: 8px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.leaflet-popup.lw-pop .pop-btn.is-on { background: #3a2f14; border-color: var(--gold); color: var(--gold); }
.leaflet-popup.lw-pop a.leaflet-popup-close-button { color: var(--muted); }

@media (max-width: 760px) {
  html, body { height: 100%; overflow: hidden; }
  .top { flex-wrap: nowrap; gap: 8px; padding: 8px 12px; height: 48px; }
  .top h1 { font-size: 15px; white-space: nowrap; }
  .top .views, .top #me { display: none; }
  .top .srv { font-size: 0; }
  .top .srv select { font-size: 13px; margin-left: 0; max-width: 110px; }
  .top .pill { font-size: 11px; padding: 1px 6px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top .btn { padding: 5px 10px; font-size: 13px; white-space: nowrap; flex: none; }
  .top h1 { flex: none; }
  .top .spacer { min-width: 0; }
  .layout { display: block; height: calc(100% - 48px - 58px - env(safe-area-inset-bottom)); }
  .side, .content { height: 100%; }
  .side { border-right: 0; }
  body[data-mtab="players"] .content { display: none; }
  body[data-mtab="map"] .side, body[data-mtab="screens"] .side { display: none; }
  .content.view-split { grid-template-columns: 1fr; }
  .wall { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .content.view-split .wall { grid-template-columns: 1fr; }
  .map-pane { border-right: 0; }
  .legend { font-size: 11px; gap: 8px; padding: 5px 8px; }
  .legend .lg-help { display: none; }
  #players li { padding: 10px 8px; }
  #players .add { font-size: 13px; padding: 7px 12px; }
  .tile .label { padding: 8px; font-size: 13px; }
  .tile .label .x, .tile .label .loc, .tile .label .fs { padding: 4px 9px; font-size: 15px; }
  .mtabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--panel); border-top: 1px solid var(--line); z-index: 1000; }
  .mtabs button { flex: 1; background: transparent; border: 0; color: var(--muted); font: inherit; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
  .mtabs button svg { width: 20px; height: 20px; fill: currentColor; }
  .mtabs button.on { color: var(--text); }
  .mtabs button.on svg { fill: var(--accent2); }
  .mtabs .cnt { position: absolute; margin: -22px 0 0 26px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #111; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
  .mtabs .cnt[hidden] { display: none; }
  .mtabs button { position: relative; }
}
