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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0c10;
  font-family: system-ui, sans-serif;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: grab;
}

#game.panning {
  cursor: grabbing;
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  background: rgba(20, 24, 32, 0.82);
  border: 1px solid #2a3140;
  border-radius: 8px;
  color: #c4ccd8;
  font-size: 13px;
  line-height: 1.7;
  user-select: none;
}

#hud b { color: #7aa2ff; }

#coords, #zoomReadout, #seedReadout {
  color: #8a94a6;
  font-variant-numeric: tabular-nums;
}

#regenBtn, #menuBtn {
  margin-top: 8px;
  margin-right: 6px;
  padding: 6px 12px;
  font-size: 13px;
  color: #dce3ee;
  background: #2a3550;
  border: 1px solid #3a4a6a;
  border-radius: 6px;
  cursor: pointer;
}

#regenBtn:hover, #menuBtn:hover { background: #344066; }

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 16, 0.9);
  transition: opacity 0.2s ease;
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-box {
  text-align: center;
  color: #c4ccd8;
}

.loading-title {
  font-size: 15px;
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

.progress-track {
  width: 280px;
  height: 8px;
  background: #1c2230;
  border: 1px solid #2a3140;
  border-radius: 999px;
  overflow: hidden;
}

#progressBar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4a90c2, #7aa2ff);
  transition: width 0.1s linear;
}

/* ---- Menu / lobby overlay ---- */
#menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 30%, #15203a, #0a0c10 70%);
  z-index: 10;
}

#menu.hidden { display: none; }

.menu-panel {
  width: 420px;
  max-width: 92vw;
  background: rgba(20, 24, 32, 0.92);
  border: 1px solid #2a3140;
  border-radius: 12px;
  padding: 28px 26px;
  color: #c4ccd8;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.5);
}

.screen { display: none; }
.screen.active { display: block; }

.game-title {
  text-align: center;
  font-size: 30px;
  font-weight: 700;
  color: #e6ecf5;
  margin-bottom: 24px;
  letter-spacing: 0.5px;
}

.screen h2 {
  font-size: 20px;
  color: #e6ecf5;
  margin-bottom: 18px;
}

.big-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-bottom: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #3a4f80, #2c3c63);
  border: 1px solid #46598a;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.big-btn:hover { background: linear-gradient(180deg, #46599a, #364876); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8a94a6;
  margin-bottom: 6px;
}

.menu-panel input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  font-size: 14px;
  color: #e6ecf5;
  background: #131825;
  border: 1px solid #2a3140;
  border-radius: 6px;
}
.menu-panel input[type="text"]:focus {
  outline: none;
  border-color: #4a90c2;
}

.create-row {
  display: flex;
  gap: 8px;
}
.create-row input { flex: 1; }

#btnCreate, .lobby-row button, #btnStart {
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: #2f6f9e;
  border: 1px solid #3d83b6;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
#btnCreate:hover, .lobby-row button:hover { background: #3a82b5; }
.lobby-row button:disabled {
  background: #2a3140;
  border-color: #2a3140;
  color: #6b7280;
  cursor: default;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #8a94a6;
  margin: 18px 0 8px;
}

.link-btn {
  background: none;
  border: none;
  color: #7aa2ff;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 4px;
}
.link-btn:hover { color: #9cbcff; }

.lobby-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid #232a38;
  border-radius: 8px;
}

.lobby-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #1c2230;
}
.lobby-row:last-child { border-bottom: none; }
.lobby-info { display: flex; flex-direction: column; }
.lobby-info b { color: #e6ecf5; font-size: 14px; }
.lobby-info span { color: #8a94a6; font-size: 12px; margin-top: 2px; }

.lobby-list .empty {
  padding: 20px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}

.player-list {
  list-style: none;
  margin-bottom: 18px;
  border: 1px solid #232a38;
  border-radius: 8px;
  overflow: hidden;
}
.player-list li {
  padding: 9px 12px;
  font-size: 14px;
  border-bottom: 1px solid #1c2230;
}
.player-list li:last-child { border-bottom: none; }
.player-list li.me { color: #7aa2ff; font-weight: 600; }

.waiting {
  text-align: center;
  color: #8a94a6;
  font-size: 13px;
  padding: 10px;
}

.menu-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}
#connStatus { font-size: 12px; color: #c2706e; }
#connStatus.ok { color: #6fae6f; }

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  background: rgba(20, 24, 32, 0.95);
  border: 1px solid #3a4a6a;
  border-radius: 8px;
  color: #e6ecf5;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
