/* ==========================================================================
   Petty Theft Island - online multiplayer UI (lobby panel, toasts, badge, banner)
   Owner: role "ui". Every rule is scoped to .mp-panel / #mp-* so nothing existing is affected.
   Reuses the game's tokens from style.css (--gti-font-title, --gti-accent, --gti-line ...).
   ========================================================================== */
.mp-off { display: none !important; }

/* ------------------------------------------------------------------ lobby panel (inside #pause-content) */
.mp-panel { font: 14px/1.45 var(--gti-font-ui); color: #fff; }
.mp-panel .mp-note { margin: 0 0 6px; max-width: 540px; opacity: .72; }
.mp-panel .mp-invite { opacity: 1; color: var(--gti-gold); margin-top: 10px; }
.mp-panel h3 { margin-top: 18px; }

.mp-panel input[type=text] {
  pointer-events: auto; user-select: text; -webkit-user-select: text;
  display: block; width: 280px; max-width: 100%;
  background: #1d2029; color: #fff; border: 1px solid var(--gti-line); border-radius: 4px;
  padding: 9px 12px; font: 16px var(--gti-font-ui); outline: none;
}
.mp-panel input[type=text]::placeholder { color: rgba(255, 255, 255, .35); }
.mp-panel input[type=text]:focus { border-color: var(--gti-accent); box-shadow: 0 0 0 2px rgba(255, 77, 141, .28); }
.mp-panel input[type=text]:disabled { opacity: .45; }

.mp-btn {
  pointer-events: auto; display: inline-block; min-width: 130px; text-align: center; cursor: pointer;
  background: rgba(255, 255, 255, .07); color: #fff;
  border: 1px solid var(--gti-line); border-left: 4px solid var(--gti-accent); border-radius: 3px;
  font: 22px var(--gti-font-title); letter-spacing: 1px; padding: 8px 18px;
}
.mp-btn:hover:not(:disabled) { background: linear-gradient(90deg, rgba(255, 77, 141, .45), rgba(255, 77, 141, .08)); }
.mp-btn:focus-visible { outline: 2px solid var(--gti-gold); outline-offset: 2px; }
.mp-btn:disabled { opacity: .32; cursor: default; }
.mp-btn.primary { width: 280px; max-width: 100%; background: linear-gradient(90deg, rgba(255, 77, 141, .5), rgba(255, 77, 141, .1)); }
.mp-btn.primary:hover:not(:disabled) { background: linear-gradient(90deg, rgba(255, 77, 141, .75), rgba(255, 77, 141, .18)); }
.mp-btn.danger { border-left-color: var(--gti-red); }
.mp-btn.danger:hover:not(:disabled) { background: linear-gradient(90deg, rgba(224, 49, 59, .5), rgba(224, 49, 59, .08)); }

.mp-joinrow { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; }
#mp-code {
  width: 168px; text-align: center; text-transform: uppercase;
  font: 28px var(--gti-font-title); letter-spacing: 8px; padding: 5px 4px 3px 12px;
}
#mp-code::placeholder { letter-spacing: 4px; }

.mp-status { min-height: 22px; margin: 16px 0 10px; font: 15px var(--gti-font-ui); opacity: .9; }
.mp-status.err { color: #ff8a90; opacity: 1; }
#mp-cancel { margin-top: 2px; }

/* connected view */
#mp-code-big {
  display: inline-block; user-select: text; -webkit-user-select: text; cursor: text;
  font: 92px/1 var(--gti-font-title); letter-spacing: 14px; padding-left: 4px; margin: 2px 0 14px;
  color: var(--gti-gold); text-shadow: 3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}
.mp-linkrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#mp-link { flex: 1 1 300px; width: auto; min-width: 0; font: 13px ui-monospace, Menlo, monospace; padding: 11px 12px; }
#mp-players { display: flex; flex-direction: column; gap: 6px; max-width: 580px; margin: 4px 0 20px; }
.mp-player {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: rgba(255, 255, 255, .06); border: 1px solid var(--gti-line); border-radius: 5px;
  font: 16px var(--gti-font-ui);
}
.mp-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0, 0, 0, .65); }
.mp-pname { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; user-select: text; -webkit-user-select: text; }
.mp-fill { flex: 1 1 0; min-width: 0; }
.mp-you { flex: none; opacity: .55; }
.mp-host {
  flex: none; font: 700 10px var(--gti-font-ui); letter-spacing: 1.5px; text-transform: uppercase;
  color: #000; background: var(--gti-accent); border-radius: 3px; padding: 2px 6px;
}
.mp-away {
  flex: none; font: 700 10px var(--gti-font-ui); letter-spacing: 1.5px; text-transform: uppercase;
  color: #000; background: var(--gti-gold); border-radius: 3px; padding: 2px 6px;
}
.mp-ping, .mp-kd { flex: none; text-align: right; font-variant-numeric: tabular-nums; opacity: .8; }
.mp-ping { min-width: 62px; }
.mp-kd { min-width: 48px; color: var(--gti-gold); opacity: 1; font-weight: 700; }

/* ------------------------------------------------------------------ toasts, badge, banner (created lazily inside #ui) */
#mp-toasts {
  position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
/* pause screen open: the lobby panel already shows the roster live, so toasts would only cover its text */
body:has(#screen-pause:not(.hidden)) #mp-toasts { display: none; }
.mp-toast {
  max-width: min(560px, 90vw); text-align: center; pointer-events: none;
  font: 16px var(--gti-font-hud); letter-spacing: .3px; color: #fff;
  background: var(--gti-bg); border: 1px solid var(--gti-line); border-left: 4px solid var(--gti-blue);
  border-radius: 4px; padding: 7px 16px; text-shadow: 1px 1px 0 #000;
  animation: mp-in .18s ease-out; transition: opacity .45s, transform .45s;
}
.mp-toast.warn { border-left-color: var(--gti-gold); }
.mp-toast.err { border-left-color: var(--gti-red); }
.mp-toast.out { opacity: 0; transform: translateY(-6px); }
@keyframes mp-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

#mp-badge {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 20; pointer-events: none; white-space: nowrap;
  font: 12px var(--gti-font-hud); letter-spacing: 2px; color: #fff;
  background: rgba(8, 10, 14, .62); border: 1px solid var(--gti-line); border-radius: 11px; padding: 3px 14px; opacity: .92;
}
#mp-banner {
  position: fixed; top: 36px; left: 50%; transform: translateX(-50%); z-index: 21; pointer-events: none; text-align: center;
  max-width: min(640px, 92vw);
  font: 15px var(--gti-font-hud); letter-spacing: .4px; color: #1a1300;
  background: var(--gti-gold); border: 2px solid #000; border-radius: 4px; padding: 6px 18px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}
#mp-banner.err { background: var(--gti-red); color: #fff; }

/* ------------------------------------------------------------------ [P2] name tags over remote players (children of #hud, moved by MPUI.frame)
   .mp-tag is a zero-size anchor at the projected point (transform: translate set from JS); the pill sits above it, centred, with a small
   pointer at the anchor. Colour = the player's slot colour (inline style.color; border, pointer and text follow currentColor). */
.mp-tag {
  position: absolute; left: 0; top: 0; width: 0; height: 0; overflow: visible; z-index: 3;
  pointer-events: none; will-change: transform; transform-origin: 50% 100%;
  animation: mp-tag-in .14s ease-out;
}
.mp-tag .mp-tag-name {
  position: absolute; left: 0; bottom: 5px; transform: translateX(-50%);
  max-width: 210px; box-sizing: border-box; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 700 13px/1.25 var(--gti-font-ui); letter-spacing: .3px; padding: 1px 9px 2px;
  background: rgba(6, 8, 12, .58); border: 1px solid currentColor; border-radius: 11px;
  text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000, 0 0 4px #000;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .6);
}
.mp-tag::after {
  content: ''; position: absolute; left: -4px; bottom: 0; width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .7));
}
@keyframes mp-tag-in { from { opacity: 0; } }

/* ------------------------------------------------------------------ [P3] kill feed, scoreboard, WASTED line, spawn-protection cue
   All are siblings of #hud inside #ui (so WASTED, which hides #hud, keeps them) and are created lazily by mpui.js in a match. */
#hud-feed {
  position: absolute; top: 18px; right: 240px; z-index: 8; pointer-events: none;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: calc(100vw - 264px);
}
.mp-feed-row {
  display: flex; align-items: center; gap: 8px; white-space: nowrap; max-width: 100%;
  padding: 3px 12px 3px 10px; background: var(--gti-bg); border: 1px solid var(--gti-line); border-radius: 4px;
  font: 15px/1.25 var(--gti-font-hud); letter-spacing: .3px; text-shadow: 1px 1px 0 #000, 0 0 4px rgba(0, 0, 0, .8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  animation: mp-feed-in .16s ease-out; transition: opacity .6s ease-in, transform .6s ease-in;
}
.mp-feed-row.me { border-color: rgba(255, 210, 59, .75); background: rgba(24, 20, 6, .8); }
.mp-feed-row.out { opacity: 0; transform: translateX(14px); }
.mp-fn { min-width: 0; max-width: 190px; overflow: hidden; text-overflow: ellipsis; unicode-bidi: isolate; }
.mp-fic { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px; }
.mp-fi { display: block; height: 24px; width: auto; max-width: 52px; object-fit: contain; }
.mp-fg { display: block; width: 24px; height: 24px; fill: #fff; stroke: #0b0c10; stroke-width: 1; stroke-linejoin: round; paint-order: stroke fill; overflow: visible; }
.mp-fg .dk { fill: #0b0c10; stroke: none; }
@keyframes mp-feed-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
/* the pause and map screens cover the corner: the feed would only clutter them */
body:has(#screen-pause:not(.hidden)) #hud-feed, body:has(#screen-map:not(.hidden)) #hud-feed,
body:has(#screen-pause:not(.hidden)) #mp-prot, body:has(#screen-map:not(.hidden)) #mp-prot,
body:has(#screen-map:not(.hidden)) #mp-scoreboard { display: none; }

#mp-scoreboard {
  position: absolute; left: 50%; top: 92px; transform: translateX(-50%); z-index: 9; pointer-events: none;
  width: min(560px, calc(100vw - 32px)); padding: 12px 16px 10px;
  background: var(--gti-panel); border: 1px solid var(--gti-line); border-radius: 6px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .6); animation: mp-sb-in .12s ease-out;
}
.mp-sb-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.mp-sb-title { font: 32px/1 var(--gti-font-title); letter-spacing: 2px; color: #fff; }
.mp-sb-room { font: 12px var(--gti-font-hud); letter-spacing: 2px; opacity: .55; }
.mp-sb-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) 62px 62px 74px; column-gap: 10px; align-items: center; padding: 7px 10px; border-radius: 4px; font: 700 18px/1.2 var(--gti-font-ui); }
.mp-sb-row + .mp-sb-row { margin-top: 3px; }
.mp-sb-row:not(.mp-sb-cols) { background: rgba(255, 255, 255, .06); border-left: 3px solid transparent; }
.mp-sb-row.me { background: rgba(255, 255, 255, .13); border-left-color: var(--gti-gold); }
.mp-sb-cols { padding-top: 2px; padding-bottom: 2px; font: 700 11px var(--gti-font-ui); letter-spacing: 2px; opacity: .55; }
.mp-sb-dot { display: block; width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0, 0, 0, .65); }
.mp-sb-n { min-width: 0; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; }
.mp-sb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; unicode-bidi: isolate; text-shadow: 1px 1px 0 #000; }
.mp-sb-you { flex: none; font: 400 14px var(--gti-font-ui); opacity: .55; font-style: normal; }
.mp-sb-tag { flex: none; font: 700 10px var(--gti-font-ui); letter-spacing: 1.5px; font-style: normal; color: #000; border-radius: 3px; padding: 2px 6px; }
.mp-sb-tag.host { background: var(--gti-accent); }
.mp-sb-tag.away { background: var(--gti-gold); }
.mp-sb-c { text-align: right; font-variant-numeric: tabular-nums; }
.mp-sb-row:not(.mp-sb-cols) .k { color: var(--gti-gold); font-size: 22px; }
.mp-sb-row:not(.mp-sb-cols) .d { font-size: 22px; opacity: .9; }
.mp-sb-row:not(.mp-sb-cols) .p { font: 400 14px var(--gti-font-ui); opacity: .7; }
@keyframes mp-sb-in { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translateX(-50%); } }

/* third line of the WASTED screen (#screen-wasted is a centred flex column: t = WASTED, s = hospital bill, then this) */
#mp-wastedby {
  margin-top: 8px; font: 30px var(--gti-font-title); letter-spacing: 3px; color: #fff; text-align: center; white-space: nowrap;
  opacity: 0; animation: gti-fade .7s 1s forwards;
}
#mp-wastedby .mp-wb-name { unicode-bidi: isolate; }

/* spawn protection: a soft pulsing edge glow, and a small chip with a bar that drains over the protection time */
#mp-prot { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.mp-prot-ring {
  position: absolute; inset: 0; opacity: .3;
  box-shadow: inset 0 0 0 4px rgba(90, 190, 255, .6), inset 0 0 110px 14px rgba(70, 170, 255, .38);
  animation: mp-prot-pulse .55s ease-in-out infinite alternate;
}
.mp-prot-chip {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); min-width: 150px; text-align: center;
  padding: 4px 16px 6px; background: rgba(8, 20, 32, .72); border: 1px solid rgba(90, 190, 255, .55); border-radius: 12px;
  font: 12px var(--gti-font-hud); letter-spacing: 2.5px; color: #bfe6ff; text-shadow: 1px 1px 0 #000;
}
.mp-prot-chip i { display: block; height: 3px; margin-top: 4px; border-radius: 2px; background: #5ac0ff; transform-origin: 0 50%; animation: mp-prot-bar 3s linear forwards; }
@keyframes mp-prot-pulse { from { opacity: .22; } to { opacity: 1; } }
@keyframes mp-prot-bar { to { transform: scaleX(0); } }

@media (max-width: 900px) {
  #mp-code-big { font-size: 64px; letter-spacing: 8px; }
}
