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

body {
  overflow: hidden;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: #000;
  color: #fff;
  user-select: none;
}

#game-container {
  position: fixed;
  inset: 0;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#hud { position: absolute; inset: 0; pointer-events: none; }

#hud-top {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
}

.hud-left, .hud-right { display: flex; gap: 8px; }

.hud-badge {
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

#conn-status.connected { color: #7dff7d; }
#conn-status.disconnected { color: #ff7d7d; }

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
}

.crosshair-line { position: absolute; background: rgba(255, 255, 255, 0.85); }
.crosshair-line.horizontal { top: 50%; left: 0; right: 0; height: 2px; transform: translateY(-50%); }
.crosshair-line.vertical { left: 50%; top: 0; bottom: 0; width: 2px; transform: translateX(-50%); }

#hotbar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: auto;
}

.hotbar-slot {
  width: 52px;
  height: 52px;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hotbar-slot.selected { border-color: #fff; background: rgba(255, 255, 255, 0.15); }

.hotbar-slot .slot-icon {
  width: 80%;
  height: 80%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
}

.hotbar-slot .slot-count {
  position: absolute;
  bottom: 1px;
  right: 4px;
  font-size: 13px;
  font-weight: bold;
  text-shadow: 1px 1px 2px #000;
}

#hint-bar {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 14px;
  border-radius: 4px;
  font-size: 13px;
  color: #ddd;
  white-space: nowrap;
}

#chat {
  position: absolute;
  left: 16px;
  bottom: 140px;
  width: 420px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 220px;
  overflow: hidden;
}

.chat-msg {
  background: rgba(0, 0, 0, 0.5);
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 13px;
  line-height: 1.4;
}

.chat-msg.system { color: #ffd75e; }
.chat-msg .user { color: #7bd0ff; font-weight: bold; }

#chat-input {
  display: none;
  padding: 6px 10px;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  outline: none;
  pointer-events: auto;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  z-index: 20;
}

.screen.hidden { display: none; }

#login-box, .login-box {
  background: rgba(20, 20, 30, 0.95);
  padding: 36px 48px;
  border-radius: 10px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.login-box h1 {
  font-size: 36px;
  margin-bottom: 8px;
  color: #6ee76e;
  letter-spacing: 2px;
}

.login-box p { color: #aaa; margin-bottom: 22px; font-size: 14px; }

.login-box input {
  display: block;
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 14px;
  font-size: 16px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  outline: none;
  text-align: center;
}

.login-box button {
  width: 100%;
  padding: 11px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 5px;
  background: #4a9eff;
  color: #fff;
  cursor: pointer;
}

.login-box button:hover { background: #6fb1ff; }

#login-status { margin-top: 12px; color: #ff9d5c; font-size: 14px; min-height: 18px; }

#inventory-screen {
  justify-content: flex-start;
  padding-top: 40px;
  background: rgba(10, 12, 18, 0.9);
}

#inventory-screen h2 {
  margin: 10px 0 8px;
  color: #eee;
  font-size: 20px;
  text-align: center;
  width: 100%;
}

.inventory-grid { display: flex; flex-direction: column; gap: 8px; }

.inv-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.inv-slot {
  width: 54px;
  height: 54px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.inv-slot:hover { background: rgba(255, 255, 255, 0.18); }

.inv-slot .slot-icon {
  width: 70%;
  height: 70%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  image-rendering: pixelated;
}

.inv-slot .slot-count {
  position: absolute;
  bottom: 1px;
  right: 4px;
  font-size: 13px;
  font-weight: bold;
  text-shadow: 1px 1px 2px #000;
}

#crafting-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 720px;
  margin-bottom: 12px;
  overflow-y: auto;
  max-height: 200px;
}

.recipe-card {
  width: 130px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
}

.recipe-card:hover { background: rgba(255, 255, 255, 0.15); }

.recipe-card .recipe-result { font-size: 13px; color: #eee; margin-bottom: 4px; }

.recipe-card .recipe-required {
  font-size: 11px;
  color: #aaa;
  line-height: 1.5;
}

.recipe-card.craftable { border-color: #6ee76e; }
.recipe-card.craftable .recipe-result { color: #6ee76e; }

.inventory-footer { margin-top: 8px; }

.inventory-footer button {
  padding: 10px 28px;
  font-size: 14px;
  border: none;
  border-radius: 5px;
  background: #4a9eff;
  color: #fff;
  cursor: pointer;
}

#toast-container {
  position: absolute;
  top: 60px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
}

.toast {
  background: rgba(0, 0, 0, 0.75);
  border-left: 3px solid #ff9d5c;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 14px;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
