* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0b0e14;
  --bar: #131826;
  --text: #dbe2f0;
  --dim: #7c8598;
  --accent: #35d0e8;
  --chip: #1d2436;
  --chip-on: #234a56;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}

#topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--bar);
  border-bottom: 1px solid #222b40;
  z-index: 10;
  overflow-x: auto;
  scrollbar-width: none;
}

#brand { font-weight: 700; white-space: nowrap; letter-spacing: .3px; }

#worlds { display: flex; gap: 4px; }
#worlds button {
  border: 0;
  background: transparent;
  color: var(--dim);
  font: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
#worlds button:hover { color: var(--text); background: var(--chip); }
#worlds button.on { color: var(--accent); background: var(--chip); font-weight: 600; }

#layers { display: flex; gap: 6px; margin-left: auto; }
.chip {
  border: 1px solid #2a3350;
  background: var(--chip);
  color: var(--dim);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.on { color: #bdf3ff; background: var(--chip-on); border-color: #2c6a7a; }

main { position: fixed; inset: 46px 0 0 0; }

#map {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  image-rendering: pixelated;
}
#map.dragging { cursor: grabbing; }

#panel {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 270px;
  max-height: calc(100% - 70px);
  overflow-y: auto;
  background: rgba(19, 24, 38, .94);
  border: 1px solid #222b40;
  border-radius: 12px;
  padding: 12px;
  z-index: 5;
}
#panel.hidden { display: none; }
#panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); margin-bottom: 8px; }

.beast-card {
  background: #182034;
  border: 1px solid #232e4a;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
}
.beast-card:hover { border-color: var(--accent); }
.beast-card .head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.beast-card .name { font-weight: 700; }
.badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge.alive { background: #10394a; color: #4be3ff; }
.badge.dead { background: #3a2430; color: #ff8f8f; }
.badge.matured { background: #34275a; color: #c9b3ff; }
.beast-card .row { display: flex; justify-content: space-between; color: var(--dim); font-size: 12.5px; }
.beast-card .row b { color: var(--text); font-weight: 600; }
.beast-card .grow { color: #6ee7a0; font-size: 12px; margin-top: 4px; }
.dim { color: var(--dim); }

#login {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 20;
}
#login.hidden { display: none; }
#loginBox {
  width: min(340px, calc(100% - 40px));
  background: var(--bar);
  border: 1px solid #222b40;
  border-radius: 14px;
  padding: 26px;
  text-align: center;
}
#loginBox h1 { font-size: 22px; margin-bottom: 8px; }
#loginBox p { margin-bottom: 14px; font-size: 13px; }
#loginBox input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #2a3350;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: center;
}
#loginBox input:focus { outline: none; border-color: var(--accent); }
#loginBox button {
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  border: 0;
  border-radius: 10px;
  background: var(--chip-on);
  color: #bdf3ff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#loginBox button:hover { filter: brightness(1.15); }
#loginBox button.ghost { background: transparent; color: var(--dim); }
#loginBox .err { color: #ff8f8f; margin-top: 4px; }
#loginBox .hidden, #loginStep2.hidden { display: none; }

#coords {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(19, 24, 38, .85);
  border-radius: 8px;
  padding: 4px 10px;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--dim);
  z-index: 5;
  pointer-events: none;
}

#status {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(19, 24, 38, .85);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--dim);
  z-index: 5;
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #f4bf4f; }
.dot.live { background: #45e07d; box-shadow: 0 0 6px #45e07d; }
.dot.busy { background: #35d0e8; box-shadow: 0 0 6px #35d0e8; }
.dot.err  { background: #ff6363; }

#zoomCtl {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}
#zoomCtl button {
  width: 36px;
  height: 36px;
  border: 1px solid #2a3350;
  border-radius: 10px;
  background: rgba(19, 24, 38, .9);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
#zoomCtl button:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 640px) {
  #panel { width: calc(100% - 20px); max-height: 45%; }
  #brand { display: none; }
}
