:root {
  --bg: #141821;
  --glass: rgba(20, 24, 33, 0.72);
  --glass-strong: rgba(20, 24, 33, 0.88);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f4f7;
  --muted: #9aa3b5;
  --accent: #6ee7b7;
  --accent-ink: #0d3b2a;
  --danger: #ff7a85;
  --radius: 16px;
  --shadow: 0 12px 40px rgba(6, 10, 18, 0.35), 0 2px 8px rgba(6, 10, 18, 0.25);
  --pixel: 'Pixelify Sans', ui-monospace, monospace;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
svg .fill {
  fill: currentColor;
  stroke: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(10, 16, 24, 0.35) 100%);
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow);
}

/* Little pixel-face logo */
.logo-mark {
  --s: 4px;
  position: relative;
  width: calc(var(--s) * 8);
  height: calc(var(--s) * 8);
  border-radius: calc(var(--s) * 2);
  background: var(--accent);
  box-shadow: inset 0 calc(var(--s) * -1) 0 rgba(0, 0, 0, 0.12);
  flex: none;
}
.logo-mark::before {
  content: '';
  position: absolute;
  left: calc(var(--s) * 2);
  top: calc(var(--s) * 3);
  width: var(--s);
  height: calc(var(--s) * 2);
  background: var(--accent-ink);
  box-shadow: calc(var(--s) * 3) 0 0 var(--accent-ink);
  animation: blink 4s infinite;
}
.logo-mark.small {
  --s: 2.5px;
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.15); }
}

/* ------------------------------------------------------------------ Join */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: linear-gradient(180deg, rgba(14, 20, 30, 0.25), rgba(14, 20, 30, 0.55));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
  transition: opacity 0.4s ease;
  z-index: 10;
}
.overlay.leaving {
  opacity: 0;
  pointer-events: none;
}

.card {
  width: min(620px, 100%);
  padding: 28px;
  border-radius: 24px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand h1 {
  margin: 0;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 40px;
  letter-spacing: 0.5px;
  line-height: 1;
}
.tagline {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.join-grid {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 22px;
  align-items: start;
}

.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 10px 12px;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 70%, rgba(110, 231, 183, 0.18), transparent 60%),
    repeating-conic-gradient(rgba(255, 255, 255, 0.03) 0 25%, transparent 0 50%) 0 0 / 20px 20px;
  border: 1px solid var(--line);
}
#preview {
  width: 160px;
  height: 178px;
  image-rendering: pixelated;
}
.preview-controls {
  display: flex;
  gap: 6px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.icon-btn:active {
  transform: scale(0.94);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

.custom {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.22);
  outline: none;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(110, 231, 183, 0.15);
}
.field input::placeholder {
  color: #6c7487;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.12s;
}
.swatch:hover {
  transform: translateY(-1px);
}
.swatch.selected {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-transform: capitalize;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover {
  background: rgba(255, 255, 255, 0.06);
}
.chip.selected {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.primary {
  margin-top: 24px;
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14), 0 8px 24px rgba(110, 231, 183, 0.25);
  transition: transform 0.12s, filter 0.15s;
}
.primary:hover {
  filter: brightness(1.05);
}
.primary:active {
  transform: translateY(1px);
}
.primary:disabled {
  opacity: 0.7;
  cursor: progress;
}
.primary svg {
  transition: transform 0.2s;
}
.primary:hover svg {
  transform: translateX(3px);
}

.fineprint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.fineprint svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 560px) {
  .card {
    padding: 20px;
  }
  .join-grid {
    grid-template-columns: 1fr;
  }
  .brand h1 {
    font-size: 32px;
  }
}

/* ------------------------------------------------------------------ HUD */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
#hud > * {
  pointer-events: auto;
}
#hud[hidden] {
  display: none;
}

.pill {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  font-size: 14px;
}
.top-left {
  position: absolute;
  top: 16px;
  left: 16px;
}
.top-left b {
  font-family: var(--pixel);
  font-size: 17px;
  font-weight: 700;
}
.divider {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
}
.online {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 500;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 7px rgba(110, 231, 183, 0); }
  100% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0); }
}

.location {
  position: absolute;
  top: 68px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px 7px 8px;
  border-radius: 14px;
}
.compass-wrap {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 214, 90, 0.14);
  color: #ffd65a;
}
#compass {
  width: 16px;
  height: 16px;
  transition: transform 0.3s ease, opacity 0.3s;
}
.loc-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.loc-text b {
  font-family: var(--pixel);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.2px;
}
.loc-text span {
  font-size: 12px;
  color: var(--muted);
}
.location.flash .loc-text b {
  animation: region-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes region-in {
  from { opacity: 0; transform: translateY(4px); }
}

.panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 248px;
  border-radius: var(--radius);
  padding: 12px;
}
.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 2px 4px 8px;
}
.count {
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 11px;
}
#nearby-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#nearby-list li {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 10px;
  transition: background 0.2s;
}
#nearby-list li.speaking {
  background: rgba(110, 231, 183, 0.1);
}
#nearby-list canvas {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  image-rendering: pixelated;
  transition: box-shadow 0.15s;
}
#nearby-list li.speaking canvas {
  box-shadow: 0 0 0 2px var(--accent);
}
.n-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.n-bar {
  margin-top: 5px;
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.n-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.15s linear;
}
.n-icon {
  color: var(--muted);
  display: grid;
  place-items: center;
}
.n-icon svg {
  width: 16px;
  height: 16px;
}
.n-icon.muted {
  color: var(--danger);
}
.empty {
  margin: 0;
  padding: 4px 6px 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dock {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 20px;
}
.me {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 0 2px;
}
#me-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  image-rendering: pixelated;
}
.me-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 70px;
}
.me-text b {
  font-size: 14px;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-text span {
  font-size: 12px;
  color: var(--muted);
}
.sep {
  width: 1px;
  height: 28px;
  background: var(--line-strong);
  margin: 0 2px;
}
.ctl {
  --level: 0;
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.ctl:hover {
  background: rgba(255, 255, 255, 0.12);
}
.ctl:active {
  transform: scale(0.95);
}
.ctl .slash {
  opacity: 0;
  transition: opacity 0.15s;
}
.ctl.off {
  background: rgba(255, 122, 133, 0.16);
  border-color: rgba(255, 122, 133, 0.35);
  color: var(--danger);
}
.ctl.off .slash {
  opacity: 1;
}
.ctl.on {
  color: var(--accent);
}
#btn-mic::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 0 0 calc(var(--level) * 5px) rgba(110, 231, 183, calc(0.15 + var(--level) * 0.4));
  pointer-events: none;
}

.minimap-wrap {
  position: absolute;
  right: 16px;
  bottom: 18px;
  padding: 6px;
  border-radius: 14px;
}
#minimap {
  display: block;
  width: 192px;
  height: 132px;
  border-radius: 9px;
  image-rendering: pixelated;
}

.hint {
  position: absolute;
  left: 16px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: opacity 0.8s;
}
.hint span {
  opacity: 0.5;
  margin: 0 4px;
}
.hint.faded {
  opacity: 0;
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 7px;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  text-shadow: none;
}

#toasts {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  animation: toast-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.toast.out {
  animation: toast-out 0.35s ease both;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px); }
}

#reconnect {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
}
#reconnect[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .panel {
    top: 124px;
    left: 16px;
    right: auto;
    width: 220px;
  }
  .minimap-wrap,
  .hint {
    display: none;
  }
  .me-text {
    display: none;
  }
  .dock {
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

/* ------------------------------------------------------------------ Boot error */

.boot-card h2 {
  margin: 22px 0 8px;
  font-size: 20px;
}
.boot-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 15px;
}
.boot-card pre {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  font: 500 14px/1.6 ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--accent);
}
.boot-card a {
  color: var(--accent);
}
/* .overlay sets display:grid, which would otherwise override the hidden attribute */
.overlay[hidden],
.boot-card [hidden] {
  display: none;
}
#boot-error:not([hidden]) {
  background: var(--bg);
}
