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

body {
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: white;
}

#canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* --- Crosshair --- */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  font-weight: 200;
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
  z-index: 50;
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

/* --- UI Overlay --- */
#ui-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 20px 20px;
}

#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: auto;
  gap: 16px;
}

#world-name {
  font-size: 26px;
  font-weight: 700;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

#top-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#toolbar {
  display: flex;
  gap: 6px;
}

.tool-btn {
  padding: 6px 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.tool-btn:active {
  transform: translateY(0);
}

#time-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  opacity: 0.7;
}

#time-slider {
  width: 120px;
  accent-color: #6366f1;
  cursor: pointer;
}

#controls-hint {
  font-size: 11px;
  opacity: 0.45;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

/* --- Prompt Area --- */
#prompt-area {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
}

#examples {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.example-chip {
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  user-select: none;
}

.example-chip:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

#prompt-bar {
  display: flex;
  gap: 10px;
  width: 100%;
}

#prompt {
  flex: 1;
  padding: 14px 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(24px);
  color: white;
  font-size: 16px;
  outline: none;
  transition: background 0.2s, border-color 0.2s;
}

#prompt::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

#prompt:focus {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(99, 102, 241, 0.6);
}

#submit {
  padding: 14px 30px;
  border: none;
  border-radius: 14px;
  background: rgba(99, 102, 241, 0.85);
  backdrop-filter: blur(20px);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#submit:hover {
  background: rgba(99, 102, 241, 1);
  transform: translateY(-1px);
}

#submit:active {
  transform: translateY(0);
}

#submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#status-msg {
  font-size: 13px;
  opacity: 0.6;
  text-align: center;
  min-height: 18px;
}

/* --- Dialogue Panel --- */
#dialogue-panel {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  width: 440px;
  max-width: calc(100vw - 40px);
  flex-direction: column;
  background: rgba(10, 10, 20, 0.88);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  overflow: hidden;
  z-index: 60;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

#dialogue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#dialogue-name {
  font-weight: 600;
  font-size: 15px;
  color: #a5b4fc;
}

#dialogue-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

#dialogue-close:hover {
  color: white;
}

#dialogue-text {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
  color: rgba(255, 255, 255, 0.85);
}

#dialogue-text em {
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

.dlg-you {
  margin-top: 10px;
  color: #93c5fd;
}

.dlg-npc {
  margin-top: 6px;
  color: #e2e8f0;
}

#dialogue-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

#dialogue-input {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  font-size: 14px;
  outline: none;
}

#dialogue-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

#dialogue-input:focus {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(255, 255, 255, 0.1);
}

#dialogue-send {
  padding: 8px 18px;
  border: none;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.75);
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

#dialogue-send:hover {
  background: rgba(99, 102, 241, 0.95);
}

/* --- Loading --- */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  gap: 20px;
  z-index: 100;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Scrollbar --- */
#dialogue-text::-webkit-scrollbar { width: 4px; }
#dialogue-text::-webkit-scrollbar-track { background: transparent; }
#dialogue-text::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
