/* =====================================================================
   SimplexVoiceBridge – Minecraft-style web voice chat
   ===================================================================== */
@font-face { font-family: "Pixelify"; font-weight: 400; font-display: swap; src: url(fonts/pixelify-sans-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Pixelify"; font-weight: 400; font-display: swap; src: url(fonts/pixelify-sans-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Pixelify"; font-weight: 600; font-display: swap; src: url(fonts/pixelify-sans-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Pixelify"; font-weight: 700; font-display: swap; src: url(fonts/pixelify-sans-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }

:root {
  --bg: #0b0f14;
  --text: #f4f7fb;
  --muted: #a3adbb;
  --dim: #6c7686;
  --accent: #4fd6ff;
  --accent-2: #2f8cff;
  --ok: #55ff7f;
  --warn: #ffcf4a;
  --bad: #ff5b5b;
  --panel: rgba(12, 16, 22, .82);
  --panel-edge: #000;
  --panel-hi: rgba(255, 255, 255, .09);
  --panel-lo: rgba(0, 0, 0, .55);
  --btn: #737373;
  --btn-hover: #8389c4;
  --btn-active: #5b5f8f;
  --btn-disabled: #3b3b3b;
  --shadow: #3f3f3f;
  --ib: #c9d6e6;
  --px: 3px;
  --radius: 0;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pixelify", ui-monospace, monospace;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: none;
  font-smooth: never;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}
input { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; }
.hidden { display: none !important; }

#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -2; image-rendering: pixelated; }
#vignette {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(79, 214, 255, .16), transparent 55%),
    radial-gradient(ellipse at 100% 110%, rgba(47, 140, 255, .14), transparent 50%),
    radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, .75) 100%);
}

#app { min-height: 100%; display: flex; justify-content: center; padding: calc(10px + var(--safe-top)) 12px calc(18px + var(--safe-bottom)); }
.screen { display: none; width: 100%; max-width: 1040px; flex-direction: column; align-items: center; animation: fadeIn .35s ease-out; }
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- text */
.mc-shadow, .window-title, .mc-btn, .logo, .profile-name { text-shadow: 2px 2px 0 var(--shadow); }

.logo {
  position: relative;
  margin: 18px 0 6px;
  font-weight: 700;
  font-size: clamp(40px, 11vw, 74px);
  letter-spacing: .02em;
  line-height: 1;
  color: #fff;
  text-align: center;
  text-shadow:
    0 3px 0 #1d6ad6, 0 6px 0 #164f9f, 0 9px 0 #0e3366, 0 12px 18px rgba(0, 0, 0, .65);
  animation: logoIn .6s cubic-bezier(.2, 1.4, .4, 1);
}
.logo .l-accent { color: var(--accent); }
.logo::after {
  content: attr(data-splash);
  position: absolute; right: -12px; bottom: -10px;
  font-size: 18px; color: #ffff55; text-shadow: 2px 2px 0 #3f3f00;
  transform: rotate(-16deg);
  animation: splash 1.2s ease-in-out infinite alternate;
  white-space: nowrap;
}
@keyframes splash { from { transform: rotate(-16deg) scale(.94); } to { transform: rotate(-16deg) scale(1.06); } }
@keyframes logoIn { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.tagline { color: var(--muted); font-size: 18px; margin-top: 30px; text-align: center; text-shadow: 2px 2px 0 #000; }
.brand { margin: 10px 0 18px; display: flex; flex-direction: column; align-items: center; }

/* ---------------------------------------------------------------- windows */
.window {
  position: relative;
  width: 100%;
  background: var(--panel);
  border: var(--px) solid var(--panel-edge);
  box-shadow:
    inset var(--px) var(--px) 0 var(--panel-hi),
    inset calc(var(--px) * -1) calc(var(--px) * -1) 0 var(--panel-lo),
    0 10px 30px rgba(0, 0, 0, .45);
  padding: 16px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.window-title {
  text-align: center; font-size: 19px; margin: -2px 0 14px; color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.window-title .count { color: var(--dim); }

/* ---------------------------------------------------------------- buttons (Minecraft) */
.mc-btn {
  --b: var(--btn);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 6px 14px;
  border: var(--px) solid #000;
  background:
    linear-gradient(rgba(255, 255, 255, .06) 50%, transparent 50%) 0 0 / 100% 6px,
    var(--b);
  box-shadow:
    inset var(--px) var(--px) 0 rgba(255, 255, 255, .35),
    inset calc(var(--px) * -1) calc(var(--px) * -2) 0 rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  image-rendering: pixelated;
  transition: background-color .08s;
  outline: none;
}
.mc-btn:hover, .mc-btn:focus-visible { --b: var(--btn-hover); color: #ffffa0; }
.mc-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.mc-btn:active { --b: var(--btn-active); box-shadow: inset var(--px) var(--px) 0 rgba(0, 0, 0, .35); }
.mc-btn:disabled { --b: var(--btn-disabled); color: #a0a0a0; cursor: default; box-shadow: none; }
.mc-btn.wide { width: 100%; }
.mc-btn.small { min-height: 36px; padding: 2px 10px; font-size: 15px; }
.mc-btn.icon-only { padding: 2px 8px; }
.mc-btn.primary { --b: #2f6fd1; }
.mc-btn.primary:hover, .mc-btn.primary:focus-visible { --b: #3d86f5; color: #fff; }
.mc-btn.on { --b: #3d8c4f; }
.mc-btn.on:hover { --b: #4aa960; color: #fff; }
.mc-btn.off { --b: #a03838; }
.mc-btn.off:hover { --b: #c24646; color: #fff; }
.mc-btn.danger-hover:hover { --b: #c24646; color: #fff; }
.mc-btn.done { margin-top: 14px; }

/* ---------------------------------------------------------------- pixel icons */
.px-icon { display: inline-block; width: 22px; height: 22px; flex: none; color: #fff; filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, .55)); }
.px-icon svg { width: 100%; height: 100%; display: block; shape-rendering: crispEdges; }
.px-icon.big { width: 44px; height: 44px; }
.px-icon.huge { width: 64px; height: 64px; }

/* ---------------------------------------------------------------- top bar */
.topbar { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.mini-logo { font-weight: 700; font-size: 24px; color: #fff; text-shadow: 0 2px 0 #1d6ad6, 0 4px 0 #0e3366; }
.mini-logo .l-accent { color: var(--accent); }
.ping { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 15px; min-width: 64px; justify-content: flex-end; }
.ping .px-icon { width: 18px; height: 18px; }
.ping.good .px-icon { color: var(--ok); }
.ping.mid .px-icon { color: var(--warn); }
.ping.bad .px-icon { color: var(--bad); }

/* ---------------------------------------------------------------- login */
.login-window { max-width: 420px; margin-top: 8px; }
.hint { color: var(--muted); text-align: center; margin: 0 0 14px; font-size: 16px; }
.code-slots { display: flex; justify-content: center; gap: 12px; margin-bottom: 18px; }
.slot {
  width: 64px; height: 76px;
  text-align: center;
  font-family: inherit; font-weight: 700; font-size: 40px;
  color: #fff;
  caret-color: var(--accent);
  background: #1b1b1b;
  border: var(--px) solid;
  border-color: #373737 #ffffff #ffffff #373737;
  box-shadow: inset 0 0 0 var(--px) #8b8b8b;
  outline: none;
  text-shadow: 3px 3px 0 #3f3f3f;
  border-radius: 0;
  -webkit-appearance: none; appearance: none;
  transition: transform .08s;
}
.slot:focus { box-shadow: inset 0 0 0 var(--px) #8b8b8b, 0 0 0 var(--px) var(--accent); }
.slot.filled { animation: pop .15s ease-out; }
@keyframes pop { 50% { transform: scale(1.1); } }
.code-slots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.login-error { margin-top: 12px; padding: 10px 12px; background: rgba(160, 30, 30, .35); border: var(--px) solid #5c1010; color: #ffd1d1; text-align: center; }
.login-foot { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; color: var(--dim); font-size: 14px; }
.login-foot .px-icon { width: 16px; height: 16px; color: var(--dim); }
.howto { max-width: 420px; color: var(--muted); text-align: center; font-size: 15px; margin-top: 18px; text-shadow: 2px 2px 0 #000; }
.howto b { color: #ffff55; font-weight: 400; }
.qr-ready { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0 18px; text-align: center; color: var(--muted); }
.qr-ready .px-icon { color: var(--ok); }
.qr-ready p { margin: 0; }

/* ---------------------------------------------------------------- voice layout */
.layout { width: 100%; display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 12px; }
@media (min-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); align-items: start; }
  .col-side { position: sticky; top: 12px; }
}
.col-main { display: flex; flex-direction: column; gap: 14px; }

.profile { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 56px; height: 56px; image-rendering: pixelated; flex: none;
  border: var(--px) solid #000; background: #2a2f38;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .2);
}
.profile-text { flex: 1; min-width: 0; }
.profile-name { font-size: 22px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-sub { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; flex-wrap: wrap; }
.dot { width: 9px; height: 9px; background: var(--dim); box-shadow: 0 0 0 2px #000; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 2px #000, 0 0 10px var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; background: rgba(79, 214, 255, .14); border: 2px solid rgba(79, 214, 255, .45); color: var(--accent); font-size: 14px; }
.chip.web { background: rgba(255, 207, 74, .12); border-color: rgba(255, 207, 74, .45); color: var(--warn); }
.chip.be { background: rgba(85, 255, 127, .1); border-color: rgba(85, 255, 127, .4); color: var(--ok); }
.hud { width: 46px; height: 46px; display: grid; place-items: center; background: rgba(0, 0, 0, .4); border: var(--px) solid #000; }
.hud .px-icon { width: 28px; height: 28px; }
.hud.talking .px-icon { color: var(--ok); }
.hud.muted .px-icon, .hud.deaf .px-icon { color: var(--bad); }

/* talk pad */
.talk-window { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.talk-pad {
  --c: #2b3240;
  position: relative;
  width: min(260px, 70vw); aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: var(--px) solid #000;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 4px, transparent 4px 8px),
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 70%, #fff 10%), var(--c));
  box-shadow:
    inset 4px 4px 0 rgba(255, 255, 255, .14),
    inset -4px -6px 0 rgba(0, 0, 0, .45),
    0 0 0 0 transparent;
  color: #fff;
  cursor: pointer;
  touch-action: none;
  transition: background .15s, box-shadow .15s, transform .08s;
  outline: none;
}
.talk-pad:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.talk-pad .talk-label { font-size: 22px; font-weight: 700; text-shadow: 2px 2px 0 rgba(0, 0, 0, .6); }
.talk-pad .talk-sub { font-size: 14px; color: rgba(255, 255, 255, .7); text-align: center; padding: 0 12px; }
.talk-ring { position: absolute; inset: -10px; border: var(--px) solid transparent; pointer-events: none; transition: border-color .15s; }
.talk-pad.idle { --c: #263244; }
.talk-pad.talking { --c: #1f7a3c; box-shadow: inset 4px 4px 0 rgba(255, 255, 255, .2), inset -4px -6px 0 rgba(0, 0, 0, .4), 0 0 40px rgba(85, 255, 127, .45); }
.talk-pad.talking .talk-ring { border-color: rgba(85, 255, 127, .7); animation: ring 1s ease-out infinite; }
.talk-pad.muted { --c: #6b1f1f; }
.talk-pad.deaf { --c: #3a1f1f; }
.talk-pad.ptt { --c: #2d3a52; }
.talk-pad.ptt.talking { --c: #1f7a3c; }
.talk-pad.whisper.talking { --c: #6a3f9c; box-shadow: inset 4px 4px 0 rgba(255, 255, 255, .2), inset -4px -6px 0 rgba(0, 0, 0, .4), 0 0 40px rgba(180, 120, 255, .45); }
.talk-pad.whisper.talking .talk-ring { border-color: rgba(190, 140, 255, .7); }
.talk-pad.nomic { --c: #3b3b3b; }
.talk-pad:active { transform: translateY(2px); }
@keyframes ring { from { transform: scale(.96); opacity: 1; } to { transform: scale(1.08); opacity: 0; } }

.meter {
  position: relative; width: min(360px, 100%); height: 14px;
  background: #111; border: var(--px) solid #000;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .7);
  overflow: hidden;
}
.meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: repeating-linear-gradient(90deg, var(--ok) 0 6px, #3fd068 6px 8px); transition: width .05s linear; }
.meter-fill.under { background: repeating-linear-gradient(90deg, #7b8796 0 6px, #5c6673 6px 8px); }
.meter-threshold { position: absolute; top: -2px; bottom: -2px; width: 3px; background: #ffff55; box-shadow: 0 0 6px #ffff55; }

.quick { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.quick-btn { flex-direction: column; gap: 4px; min-height: 70px; font-size: 15px; padding: 6px 4px; text-align: center; line-height: 1.1; }
.quick-btn .px-icon { width: 24px; height: 24px; }
@media (max-width: 360px) { .quick-btn { font-size: 13px; } }

/* players */
.players-window { min-height: 120px; }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 62vh; overflow: auto; }
.player-list.compact { max-height: 240px; margin-bottom: 12px; }
.player {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, .04);
  border: 2px solid rgba(0, 0, 0, .6);
  transition: background .12s, border-color .12s;
}
.player.talking { background: rgba(85, 255, 127, .09); border-color: rgba(85, 255, 127, .55); }
.player .avatar { width: 32px; height: 32px; border-width: 2px; }
.player.talking .avatar { box-shadow: 0 0 0 2px var(--ok), 0 0 12px rgba(85, 255, 127, .6); }
.player .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .pname .you { color: var(--dim); }
.player .badges { display: flex; gap: 4px; align-items: center; }
.player .badges .chip { font-size: 12px; padding: 0 5px; }
.player .state .px-icon { width: 20px; height: 20px; }
.state.talking .px-icon { color: var(--ok); }
.state.whisper .px-icon { color: #c79bff; }
.state.disconnected .px-icon { color: var(--bad); }
.state.disabled .px-icon { color: var(--dim); }
.empty, .noperm { color: var(--dim); text-align: center; padding: 14px 6px; }

/* ---------------------------------------------------------------- modals */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(14px + var(--safe-top)) 12px calc(14px + var(--safe-bottom));
  background: rgba(0, 0, 0, .6);
  animation: fadeIn .18s ease-out;
}
.modal-window { max-width: 560px; max-height: 100%; overflow: auto; overscroll-behavior: contain; }
.modal-window.small { max-width: 380px; }
.row { display: flex; gap: 10px; margin-top: 12px; }
.row > * { flex: 1; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 16px 0 10px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 3px; background: rgba(255, 255, 255, .12); box-shadow: 0 2px 0 rgba(0, 0, 0, .5); }
.form { display: flex; flex-direction: column; gap: 10px; }
.mc-input { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 15px; }
.mc-input input, .mc-select select {
  font-family: inherit; font-size: 17px; color: #fff;
  background: #000; border: 2px solid #a0a0a0; padding: 9px 10px; outline: none; border-radius: 0;
  -webkit-appearance: none; appearance: none;
}
.mc-input input:focus, .mc-select select:focus { border-color: #fff; }
.type-desc { color: var(--dim); font-size: 14px; margin-top: -4px; }

.group-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.group-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255, 255, 255, .04); border: 2px solid rgba(0, 0, 0, .6); }
.group-item .gname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-item .gmeta { color: var(--dim); font-size: 14px; display: flex; gap: 6px; align-items: center; }
.group-item .px-icon { width: 18px; height: 18px; }
.group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.group-name { font-size: 20px; flex: 1; }

/* settings rows */
.settings { display: flex; flex-direction: column; gap: 8px; }
.settings h3 { margin: 12px 0 2px; font-weight: 400; font-size: 15px; color: var(--accent); text-shadow: 2px 2px 0 #000; }
.settings h3:first-child { margin-top: 0; }
.set-note { color: var(--dim); font-size: 13px; margin-top: -4px; }

/* Minecraft slider */
.mc-slider {
  position: relative; height: 44px;
  border: var(--px) solid #000; background: #1d1d1d;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .7);
  touch-action: none; cursor: pointer; overflow: hidden;
}
.mc-slider .fill { position: absolute; inset: 0 auto 0 0; background: rgba(79, 214, 255, .14); pointer-events: none; }
.mc-slider .level { position: absolute; inset: auto auto 0 0; height: 4px; background: var(--ok); pointer-events: none; transition: width .05s; }
.mc-slider .handle {
  position: absolute; top: -1px; bottom: -1px; width: 16px; margin-left: -8px;
  background: var(--btn); border: var(--px) solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .4), inset -2px -3px 0 rgba(0, 0, 0, .35);
  pointer-events: none;
}
.mc-slider:hover .handle, .mc-slider:focus-visible .handle { background: var(--btn-hover); }
.mc-slider:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.mc-slider .label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-shadow: 2px 2px 0 var(--shadow); pointer-events: none; padding: 0 10px; text-align: center; white-space: nowrap; overflow: hidden; }
.mc-select { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 15px; }
.mc-select select { width: 100%; }

.vol-row { display: flex; align-items: center; gap: 10px; }
.vol-row .avatar { width: 32px; height: 32px; border-width: 2px; }
.vol-row .mc-slider { flex: 1; }

/* overlay + toasts */
.overlay { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0, 0, 0, .75); }
.overlay .mc-btn { max-width: 360px; min-height: 64px; font-size: 20px; }
.toasts { position: fixed; left: 50%; bottom: calc(18px + var(--safe-bottom)); transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; width: 100%;
  background: #212121; border: var(--px) solid #000;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .12), 0 8px 18px rgba(0, 0, 0, .5);
  animation: toastIn .25s cubic-bezier(.2, 1.3, .4, 1), toastOut .3s ease-in 3.2s forwards;
}
.toast .t-title { color: #ffff55; }
.toast.bad .t-title { color: #ff7a7a; }
.toast.ok .t-title { color: var(--ok); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(10px); opacity: 0; } }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, .4); }
::-webkit-scrollbar-thumb { background: #6b6b6b; border: 2px solid #000; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
